Jest: Update to v30 (breaking) - #80767
Conversation
|
Size Change: 0 B Total Size: 7.75 MB |
|
Flaky tests detected in ffadaee. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30311283325
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
manzoorwanijk
left a comment
There was a problem hiding this comment.
This looks good to me. I have only one question related to bumping the peer dep floor to v30.
- Keep
@types/jeston v30: Gutenberg TypeScript projects explicitly load the globaljesttype library, which TypeScript resolves to@types/jest. Jest's bundled/module types do not replace those global declarations.
Not sure I understand what is needed here, but I think it needs a follow up as mentioned.
| }, | ||
| "peerDependencies": { | ||
| "jest": ">=29" | ||
| "jest": ">=30" |
There was a problem hiding this comment.
Is Jest v30 totally incompatible with v29?
There was a problem hiding this comment.
Right, so the answer is a bit more nuanced, since Jest 30 is not totally incompatible with Jest 29.
- The 30+ requirement still needs to be applied to preset and console packages (
@wordpress/scripts,@wordpress/jest-preset-defaultand@wordpress/jest-console); - The remaining standalone matcher/fixture packages (ie
@wordpress/jest-puppeteer-axeand@wordpress/e2e-tests) can keep the 29+ requirement
I'll make changes accordingly
My bad, I didn't explain myself clearly. At this point in time, I don't think we have to follow up for It should stay and move to v30 because Gutenberg’s TypeScript tests use Jest globals, and their configured Moving to imported |
There was a problem hiding this comment.
Aside: Maybe we should customize so .snap files are shown collapsed by default similar to lock files.
There was a problem hiding this comment.
Worth noting that since these changes, there are two additional warnings when installing dependencies about an outdated glob dependency:
npm warn deprecated glob@10.5.0: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
This technically happens already with another 10.5.0 instance coming from #79618 or earlier, but ideally we could figure out a way to get on a supported version. Does the latest version of Jest still use this deprecated dependency version?
There was a problem hiding this comment.
Yeah, unless we want to add dedicated overrides, there isn't much else we can do here?
There was a problem hiding this comment.
It looks like it's been reported upstream at least: jestjs/jest#16291
Based on the timing of the issue, maybe the deprecations are new.
| @@ -0,0 +1,9 @@ | |||
| const preset = require( '@wordpress/jest-preset-default' ); | |||
There was a problem hiding this comment.
This self-import might need the exports to be set for the package to use Node's self-referencing imports. Otherwise, it breaks in isolated mode.
There was a problem hiding this comment.
This package now needs @types/node explicitly which was probably previously set by some Jest global. See the failed run in isolated deps mode.
What?
Closes #72593.
Updates Gutenberg's first-party Jest toolchain and related integrations from Jest 29 to Jest 30.
Breaking change
@wordpress/scripts,@wordpress/jest-preset-default, and@wordpress/jest-consolenow require Jest 30 or newer. Consumers of these packages must upgrade their Jest toolchain together.This does not change Gutenberg's production runtime or editor behavior.
Why?
Jest 30 is the current major release. The previous update attempt in #72778 predates the workspace migration and does not cover the resolver, preset, snapshot, or package-contract changes required by the current repository.
How?
@wordpress/*/src/*unit-test imports under Jest 30's package-exports-aware resolver.@wordpress/jest-preset-defaultresolve to its preset when loaded as a package.--testPathPatternsdocumentation.@types/jeston v30 to align the global Jest types used by Gutenberg's TypeScript tests with the Jest 30 runtime.@testing-library/jest-domon v6: v7 requires Node 22 while Gutenberg supports Node 20. Follow up after the Node 24 LTS upgrade tracked in Framework: Update Node.js version to v24 LTS #72973 (prepared in Framework: Update Node.js to v24 LTS and npm to v11 #80395).Follow-ups
testEnvironmentOptions.globalsCleanup: 'on'in a focused PR, with full CI and timing/memory evidence; fix only confirmed cross-file global leaks.jest.advanceTimersToNextFrame()opportunistically in animation tests that need a browser frame boundary. Do not perform a broad timer rewrite.Testing Instructions
npm ci.npm run build.npm run test:unit -- --runInBand.The full serial run exposed and this PR fixes Jest-specific preset, resolver, and Tooltip timeout failures. Its only environment-dependent failure was
packages/env/lib/config/test/config-integration.js, whose tests require a cached current WordPress version or network access; the sandbox has neither.Testing Instructions for Keyboard
Not applicable: this changes test tooling only.
Use of AI Tools
Codex assisted with research, implementation, and verification.