Skip to content

Jest: Update to v30 (breaking) - #80767

Merged
ciampo merged 3 commits into
trunkfrom
codex/jest-30
Jul 28, 2026
Merged

Jest: Update to v30 (breaking)#80767
ciampo merged 3 commits into
trunkfrom
codex/jest-30

Conversation

@ciampo

@ciampo ciampo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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-console now 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?

  • Align the Jest packages, Jest types, Jest ESLint plugin, reporters, and watch plugins with Jest 30.
  • Preserve deep @wordpress/*/src/* unit-test imports under Jest 30's package-exports-aware resolver.
  • Make @wordpress/jest-preset-default resolve to its preset when loaded as a package.
  • Update snapshot metadata and the renamed --testPathPatterns documentation.
  • Keep @types/jest on v30 to align the global Jest types used by Gutenberg's TypeScript tests with the Jest 30 runtime.
  • Keep @testing-library/jest-dom on 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

  • Evaluate testEnvironmentOptions.globalsCleanup: 'on' in a focused PR, with full CI and timing/memory evidence; fix only confirmed cross-file global leaks.
  • Adopt jest.advanceTimersToNextFrame() opportunistically in animation tests that need a browser frame boundary. Do not perform a broad timer rewrite.

Testing Instructions

  1. Run npm ci.
  2. Run npm run build.
  3. Run 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.

@github-actions github-actions Bot added [Package] Server Side Render /packages/server-side-render [Package] Core data /packages/core-data [Package] Components /packages/components [Package] Editor /packages/editor [Package] Block library /packages/block-library [Package] Rich text /packages/rich-text [Package] Block editor /packages/block-editor [Package] Edit Post /packages/edit-post [Package] Interactivity /packages/interactivity [Package] DataViews /packages/dataviews [Package] Theme /packages/theme [Package] UI /packages/ui [Package] Sync /packages/sync labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.75 MB

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in ffadaee.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30311283325
📝 Reported issues:

@ciampo
ciampo requested a review from Copilot July 28, 2026 02:50
@ciampo ciampo self-assigned this Jul 28, 2026
@ciampo ciampo changed the title Jest: Update to v30 Jest: Update to v30 (breaking) Jul 28, 2026

This comment was marked as resolved.

@ciampo ciampo added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Jul 28, 2026
@ciampo
ciampo marked this pull request as ready for review July 28, 2026 03:34
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo mentioned this pull request Jul 28, 2026

@manzoorwanijk manzoorwanijk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I have only one question related to bumping the peer dep floor to v30.

  • Keep @types/jest on v30: Gutenberg TypeScript projects explicitly load the global jest type 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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Jest v30 totally incompatible with v29?

@ciampo ciampo Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-default and @wordpress/jest-console);
  • The remaining standalone matcher/fixture packages (ie @wordpress/jest-puppeteer-axe and @wordpress/e2e-tests) can keep the 29+ requirement

I'll make changes accordingly

@ciampo

ciampo commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author
  • Keep @types/jest on v30: Gutenberg TypeScript projects explicitly load the global jest type 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.

My bad, I didn't explain myself clearly. At this point in time, I don't think we have to follow up for @types/jest.

It should stay and move to v30 because Gutenberg’s TypeScript tests use Jest globals, and their configured types: ["jest"] resolves to @types/jest. So in this PR, I'm keeping type defs aligned with the runtime.

Moving to imported @jest/globals types would be a separate follow-up migration that, at this point in time, I don't plan on working on. Unless you think it's a valuable refactor?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside: Maybe we should customize so .snap files are shown collapsed by default similar to lock files.

Ref: https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github

@ciampo
ciampo enabled auto-merge (squash) July 28, 2026 14:57
@ciampo
ciampo merged commit 0af03a5 into trunk Jul 28, 2026
59 checks passed
@ciampo
ciampo deleted the codex/jest-30 branch July 28, 2026 15:32
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 28, 2026
Comment thread package-lock.json

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, unless we want to add dedicated overrides, there isn't much else we can do here?

@aduth aduth Jul 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' );

@manzoorwanijk manzoorwanijk Jul 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #80837

@manzoorwanijk manzoorwanijk Jul 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package now needs @types/node explicitly which was probably previously set by some Jest global. See the failed run in isolated deps mode.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in #80838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Components /packages/components [Package] Core data /packages/core-data [Package] DataViews /packages/dataviews [Package] Edit Post /packages/edit-post [Package] Editor /packages/editor [Package] Interactivity /packages/interactivity [Package] Rich text /packages/rich-text [Package] Server Side Render /packages/server-side-render [Package] Sync /packages/sync [Package] Theme /packages/theme [Package] UI /packages/ui [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update to Jest 30

4 participants