Skip to content

Support Babel 8 in plugins and presets #15750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicolo-ribaudo
Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo commented Jul 28, 2025

Summary

The only remaining blocker for the Babel 8 stable release is to make sure that it works for major Babel consumers. This PR is the first step towards making Jest ready for it. It updates babel-plugin-jest-hoist, babel-preset-jest and babel-jest to support running with Babel 8 in addition to supporting Babel 7.

Test plan

Tests updated to run both with Babel 7 and Babel 8.

Unfortunately, while the Babel plugins/presets maintained in this repo work reasonably well with Babel 8, Babel 8 itself cannot be loaded inside Jest-run tests, because it's written in ESM. Or maybe it's possible, but not the way that Jest is configured in this repo.

As a workaround, I'm loading the Babel 8 ESM packages using Node.js' native require, rather than Jest's sandboxed version.

Most of the diff in tests is indentation changes. I suggest disabling whitespace diff when reviewing.

(fyi @JLHwung @liuxingbaoyu)

Copy link

netlify bot commented Jul 28, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1813d34
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/688b84ebfa9bfa0008d79e32
😎 Deploy Preview https://deploy-preview-15750--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

pkg-pr-new bot commented Jul 28, 2025

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15750

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15750

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15750

create-jest

npm i https://pkg.pr.new/create-jest@15750

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15750

expect

npm i https://pkg.pr.new/expect@15750

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15750

jest

npm i https://pkg.pr.new/jest@15750

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15750

jest-circus

npm i https://pkg.pr.new/jest-circus@15750

jest-cli

npm i https://pkg.pr.new/jest-cli@15750

jest-config

npm i https://pkg.pr.new/jest-config@15750

@jest/console

npm i https://pkg.pr.new/@jest/console@15750

@jest/core

npm i https://pkg.pr.new/@jest/core@15750

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15750

jest-diff

npm i https://pkg.pr.new/jest-diff@15750

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15750

jest-each

npm i https://pkg.pr.new/jest-each@15750

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15750

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15750

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15750

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15750

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15750

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15750

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15750

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15750

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15750

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15750

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15750

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15750

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15750

jest-mock

npm i https://pkg.pr.new/jest-mock@15750

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15750

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15750

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15750

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15750

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15750

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15750

jest-runner

npm i https://pkg.pr.new/jest-runner@15750

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15750

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15750

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15750

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15750

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15750

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15750

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15750

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15750

@jest/types

npm i https://pkg.pr.new/@jest/types@15750

jest-util

npm i https://pkg.pr.new/jest-util@15750

jest-validate

npm i https://pkg.pr.new/jest-validate@15750

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15750

jest-worker

npm i https://pkg.pr.new/jest-worker@15750

pretty-format

npm i https://pkg.pr.new/pretty-format@15750

commit: 1813d34

@nicolo-ribaudo nicolo-ribaudo force-pushed the babel-8-2 branch 2 times, most recently from 501bd08 to 0d9a720 Compare July 28, 2025 16:36
@nicolo-ribaudo nicolo-ribaudo marked this pull request as draft July 30, 2025 13:42
@nicolo-ribaudo nicolo-ribaudo force-pushed the babel-8-2 branch 5 times, most recently from 2e3d659 to be3b812 Compare July 30, 2025 15:18
@nicolo-ribaudo
Copy link
Contributor Author

Ok I give up. @cpojer / @SimenB do you know how to solve that "› 12 obsolete snapshots found" error in Node.js 18, which I assume is due to those tests being skipped in Node.js 18?

@nicolo-ribaudo nicolo-ribaudo marked this pull request as ready for review July 30, 2025 21:14
@cpojer
Copy link
Member

cpojer commented Jul 31, 2025

I assume we'll release this as a major, and we'll drop Node 18 next so don't worry about those.

@nicolo-ribaudo
Copy link
Contributor Author

Oh I was planning to go with this PR first just allowing users to use Babel 8, and then a separate one (major) upgrading the whole repo to it. I'll do the whole upgrade immediately then.

In:
- babel-plugin-jest-hoist
- babel-preset-jest
- babel-jest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants