Gutenberg has finished moving its JavaScript unit and integration tests from Jest to Vitest, and the change introduces support for modern JavaScript modules and allows selected tests to run in a real browser.
The migration also changes how Gutenberg’s testing setup is configured. Tests can now use Node, jsdom, or a real-browser environment depending on their requirements, while the WordPress tooling has also been updated to use Vitest by default.
Why Gutenberg moved to Vitest
Gutenberg’s JavaScript testing setup had to accommodate the growing use of ECMAScript modules (ESM) among its dependencies. Its previous Jest setup was based on CommonJS and required additional compatibility configuration. This included maintaining a list of dependencies that Babel needed to transform for Jest, meaning dependency updates could also require changes to the test configuration.
With Vitest, Gutenberg can use native ESM support instead of relying on the same compatibility workarounds. Tests run in Node by default, while jsdom and Browser Mode can be selected when a test requires them. Browser Mode also allows focused unit and integration tests to run in a real browser, where component tests can check computed styles, element sizes, scrolling, focus, and keyboard interactions. jsdom remains available for DOM tests that do not depend on browser rendering.
The project also cited maintainability in its decision to move away from Jest. Jest’s maintainers had acknowledged a period of slower progress and fewer releases, while Gutenberg could share the Vite tooling it already uses with Storybook. Vitest’s compatibility with Jest APIs also allowed the migration to be carried out incrementally.
The migration changes how Gutenberg tests are written and assigned to environments. Tests now import APIs such as describe, test, expect, and vi directly from Vitest. Their filenames determine whether they run in Node, jsdom, or Browser Mode. The main contributor commands remain npm test and npm run test:unit.
The change also affects the WordPress testing tools used by other projects. Starting with @wordpress/scripts 36.0.0, wp-scripts test-unit-js uses the Vitest installation provided by the project. The release includes breaking changes to test configuration, dependencies, APIs, and command-line options. New test setups are responsible for installing and configuring the runner and supporting dependencies they need.
Existing projects have two options: move to Vitest or continue using Jest. Projects staying with Jest need to switch from wp-scripts test-unit-js to wp-scripts test-unit-jest, install the required Jest dependencies directly, and configure the project explicitly. Existing Jest tests and snapshots can remain on Jest. The test-unit-jest command remains a maintenance-only option with no scheduled removal, while new testing features target Vitest.
The migration also deprecates @wordpress/jest-preset-default and @wordpress/jest-console. Their published versions remain available for existing Jest projects, but there are no corresponding @wordpress/vitest-preset-default or @wordpress/vitest-console packages.
Questions and feedback on the migration can be shared in the #core-editor Slack channel or through the migration tracking issue on GitHub.