Skip to content

Migrate active unit tests from Jest to Vitest - #80992

Draft
ciampo wants to merge 8 commits into
codex/vitest-consolidated-03-projects-browserfrom
codex/vitest-consolidated-04-test-migration
Draft

Migrate active unit tests from Jest to Vitest#80992
ciampo wants to merge 8 commits into
codex/vitest-consolidated-03-projects-browserfrom
codex/vitest-consolidated-04-test-migration

Conversation

@ciampo

@ciampo ciampo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What?

See #80855.

TL;DR: Migrates the active package and integration test suites from Jest APIs to explicit Vitest imports, mocks, timers, snapshots, and project-scoped environments. The stack now routes 1,001 tests through Vitest and leaves five Jest tooling suites for the dedicated cleanup/cutover PRs.

Why?

This is the main test-conversion step in the consolidated Jest-to-Vitest migration. It preserves the existing test intent and CI partition while making Vitest the runner for nearly the entire active suite.

How?

  • Converts package and integration tests to explicit vitest APIs with globals disabled.
  • Routes browser-like tests to jsdom and platform/tooling tests to Node without per-file environment directives.
  • Preserves Babel behavior, package source aliases, CSS/worker/WASM mocks, setup order, console matchers, fake timers, snapshot serializers, source locations, sharding, date/timezone coverage, and Flakiness.io identity.
  • Adds exact routed-test type checking and requires each owning workspace to declare the same Vitest version.
  • Adds narrow temporary bridges for the untyped @wordpress/block-editor store and @wordpress/interface package; publishing complete package declarations remains the follow-up documented in Migrate JavaScript unit and integration tests from Jest to Vitest #80855.
  • Makes the 100,000-block reducer test's 10-second headroom explicit. Jest allowed the synchronous operation to finish after five seconds, while Vitest reports its five-second elapsed timeout after the operation returns.
  • Marks mocked taxonomy records and queries resolved so shard ordering cannot leave a late Core Data network request.
  • Keeps the five remaining Jest tooling suites explicitly isolated for the later browser/tooling and final-cleanup PRs.
Snapshot review

All 79 changed snapshot files were reviewed. Changes are runner headers and nested-suite key formatting, except for the tested Emotion serializer normalization that replaces generated hashes while retaining stable component labels.

Testing Instructions

npm run test:unit:routing
npm run test:unit:conventions
npm run test:unit -- --runInBand
npm run test:unit:vitest -- --shard=1/4
npm run test:unit:vitest -- --shard=2/4
npm run test:unit:vitest -- --shard=3/4
npm run test:unit:vitest -- --shard=4/4
npm run test:unit:vitest -- --project vitest --run packages/block-editor/src/store/test/performance.js
npm run lint:js -- --quiet
npm run lint:pkg-json
npm run lint:lockfile
npm run lint:tsconfig

The focused PostTaxonomies test, exact 1,001-file Vitest convention/type graph, and rebuilt full stack pass after resolving the taxonomy fixture. The repository-wide Markdown and dependency lint commands still report their pre-existing baselines; the changed documentation lines introduce no new Markdown violations.

Testing Instructions for Keyboard

Not applicable; this changes test infrastructure and test implementations, not UI behavior.

Screenshots or screencast

Not applicable.

Use of AI Tools

Codex was used to implement the migration, run verification, and perform adversarial self-review. The results and changes were reviewed by the author.

@github-actions github-actions Bot added [Package] Element /packages/element [Package] Date /packages/date [Package] Data /packages/data [Package] Server Side Render /packages/server-side-render [Package] A11y /packages/a11y [Package] Autop /packages/autop [Package] DOM ready /packages/dom-ready [Package] Hooks /packages/hooks [Package] i18n /packages/i18n [Package] is-shallow-equal /packages/is-shallow-equal [Package] Url /packages/url [Package] Word count /packages/wordcount [Package] Deprecated packages/deprecated [Package] Blob /packages/blob [Package] Compose /packages/compose [Package] Core data /packages/core-data [Package] API fetch /packages/api-fetch [Package] Viewport /packages/viewport [Package] DOM /packages/dom [Package] Keycodes /packages/keycodes [Package] Plugins /packages/plugins [Package] Components /packages/components [Package] Blocks /packages/blocks [Package] Editor /packages/editor [Package] Redux Routine /packages/redux-routine [Package] Block library /packages/block-library [Package] Notices /packages/notices [Package] Token List /packages/token-list [Package] Format library /packages/format-library [Package] Rich text /packages/rich-text labels Jul 30, 2026
@github-actions github-actions Bot added [Package] Private APIs /packages/private-apis [Package] Commands /packages/commands [Package] Core commands [Package] Interactivity /packages/interactivity [Package] Patterns /packages/patterns [Package] DataViews /packages/dataviews [Package] Interactivity Router /packages/interactivity-router [Package] Fields /packages/fields [Package] Theme /packages/theme [Package] UI /packages/ui [Package] Sync labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +8 B (0%)

Total Size: 7.76 MB

📦 View Changed
Filename Size Change
build/scripts/compose/index.min.js 11.6 kB +2 B (+0.02%)
build/scripts/editor/index.min.js 500 kB +6 B (0%)

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 58ecf75.
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/30582519123
📝 Reported issues:

@ciampo
ciampo force-pushed the codex/vitest-consolidated-03-projects-browser branch from d81f25e to f9682b1 Compare July 30, 2026 23:46
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 58ecf75 to 59f56a3 Compare July 30, 2026 23:47
@ciampo
ciampo force-pushed the codex/vitest-consolidated-03-projects-browser branch from f9682b1 to 45dbb01 Compare July 31, 2026 00:38
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 59f56a3 to 8a81022 Compare July 31, 2026 00:38
@ciampo
ciampo force-pushed the codex/vitest-consolidated-03-projects-browser branch from 45dbb01 to 3a61746 Compare July 31, 2026 01:12
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 8a81022 to 6093aa4 Compare July 31, 2026 01:12
@ciampo
ciampo force-pushed the codex/vitest-consolidated-03-projects-browser branch from 3a61746 to 9878da6 Compare July 31, 2026 02:57
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 56286a1 to 212550f Compare July 31, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] A11y /packages/a11y [Package] API fetch /packages/api-fetch [Package] Autop /packages/autop [Package] Blob /packages/blob [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Blocks /packages/blocks [Package] Commands /packages/commands [Package] Components /packages/components [Package] Compose /packages/compose [Package] Core commands [Package] Core data /packages/core-data [Package] Data Controls /packages/data-controls [Package] Data /packages/data [Package] DataViews /packages/dataviews [Package] Date /packages/date [Package] Deprecated packages/deprecated [Package] DOM ready /packages/dom-ready [Package] DOM /packages/dom [Package] Edit Post /packages/edit-post [Package] Edit Site /packages/edit-site [Package] Edit Widgets /packages/edit-widgets [Package] Editor /packages/editor [Package] Element /packages/element [Package] Escape HTML /packages/escape-html [Package] Fields /packages/fields [Package] Format library /packages/format-library [Package] Hooks /packages/hooks [Package] i18n /packages/i18n [Package] Interactivity Router /packages/interactivity-router [Package] Interactivity /packages/interactivity [Package] Interface /packages/interface [Package] is-shallow-equal /packages/is-shallow-equal [Package] Keycodes /packages/keycodes [Package] Media Utils /packages/media-utils [Package] Notices /packages/notices [Package] Patterns /packages/patterns [Package] Plugins /packages/plugins [Package] Preferences /packages/preferences [Package] Primitives /packages/primitives [Package] Priority Queue /packages/priority-queue [Package] Private APIs /packages/private-apis [Package] Project management automation /packages/project-management-automation [Package] Redux Routine /packages/redux-routine [Package] Rich text /packages/rich-text [Package] Server Side Render /packages/server-side-render [Package] Style Engine /packages/style-engine [Package] Sync [Package] Theme /packages/theme [Package] Token List /packages/token-list [Package] UI /packages/ui [Package] Url /packages/url [Package] Viewport /packages/viewport [Package] Warning /packages/warning [Package] Word count /packages/wordcount

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant