Skip to content

Migrate active unit tests from Jest to Vitest - #80992

Draft
ciampo wants to merge 10 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 10 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

Part of #80855.

What?

TL;DR — test implementation changes: migrate the active package and integration suites from Jest APIs to explicit Vitest imports, mocks, timers, snapshots, and project-scoped environments. Five Jest tooling suites remain temporarily for the later cutover/cleanup PRs.

Why?

This is the main test-conversion step. It preserves existing intent and CI coverage while making Vitest the runner for Gutenberg-owned application, package, and integration tests.

How?

  • Convert Jest globals and helpers to explicit vitest imports with globals disabled.
  • Keep browser-like tests on jsdom by default and platform/tooling tests on Node.
  • Preserve package aliases, CSS/worker/WASM mocks, setup order, console matchers, fake timers, snapshot serializers, source locations, sharding, date/timezone coverage, and Flakiness.io identity.
  • Add exact routed-test type checking and require each owning workspace to declare Vitest.
  • Migrate tests added on trunk during the stack rebase, including Editor autosave, Sync, Widget Primitives, and icon-resolution coverage.
  • Review snapshot changes individually; no bulk snapshot regeneration is used as evidence.

Testing Instructions

  1. Run npm run test:unit:routing.
  2. Run npm run test:unit:conventions.
  3. Run npm run test:unit -- --runInBand.
  4. Run all four test:unit:vitest shards.
  5. Run npm run lint:js -- --quiet, npm run lint:pkg-json, npm run lint:lockfile, and npm run lint:tsconfig.

Testing Instructions for Keyboard

Not applicable; this changes tests and infrastructure, not product behavior.

Use of AI Tools

Codex assisted with implementation, conflict reconciliation, and verification. The resulting changes and test output 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 commented Jul 30, 2026

Copy link
Copy Markdown

Size Change: +12 B (0%)

Total Size: 7.78 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 501 kB +10 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
@ciampo
ciampo force-pushed the codex/vitest-consolidated-03-projects-browser branch from 9878da6 to d542198 Compare July 31, 2026 19:21
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch 3 times, most recently from ff71976 to 34a139f Compare July 31, 2026 19:46
@ciampo
ciampo force-pushed the codex/vitest-consolidated-03-projects-browser branch from 5d74e5a to aa8d0ba Compare July 31, 2026 20:00
@ciampo
ciampo force-pushed the codex/vitest-consolidated-04-test-migration branch from 34a139f to ace2c35 Compare July 31, 2026 20:01
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