Repository navigation
Test: Update Vitest to version 5 - #82687
Conversation
|
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. |
🤖 PR meta 🤖📦 Bundle sizeSize Change: +23 B (0%) Total Size: 8 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
manzoorwanijk
left a comment
There was a problem hiding this comment.
The change looks straighforward if the CI is happy.
What?
Follow up to #80855.
Updates Gutenberg's test infrastructure to Vitest 5, including the related Browser, Testing Library, jest-dom, and flakiness reporter dependencies. This is a standalone change based on
trunk.Why?
Vitest 5 requires Node 22.12 or later. Gutenberg now requires Node 24, so the repository can adopt the current major release.
This PR applies the migration changes needed by current consumers and leaves optional configuration and performance experiments for follow-ups.
How?
vitestand@vitest/browser-playwrightat 5.0.0. It also updates Testing Library React to 16.3.3, jest-dom to 7.0.1, and@flakiness/vitestto 1.9.2.describe.sequentialAPI, and changed snapshot title formatting.clearMocks: falsebecausemockReset: truealready performs the same call-history cleanup and also resets implementations..vitestartifact directory.useResizeObserveron unmount. Vitest 5's stricter error handling exposed a queued callback running during jsdom teardown.Complete release span and dependency versions
vitest4.1.11 to 5.0.0: 5.0.0@vitest/browser-playwright4.1.10 to 5.0.0: 4.1.11, 5.0.0@testing-library/react16.3.2 to 16.3.3: 16.3.3@testing-library/jest-dom6.9.1 to 7.0.1: 6.10.0, 7.0.0, 7.0.1@flakiness/vitest1.9.0 to 1.9.2: 1.9.1, 1.9.2Vitest's transitive Browser, mocker, UI, and runtime packages use the same 5.0.0 monorepo release.
@vitest/uiis new to the lockfile, so it has no earlier resolved version.Notable upstream changes
Matchers<R, T>type. One infrastructure test useddescribe.sequential. Both required migration. TypeScript and the full suite pass.useResizeObserverwork continuing after unmount, which this PR fixes and covers with a regression test.clearMocksby default. Gutenberg already enables the strongermockReset. The explicitclearMocks: falseavoids a redundant cleanup pass, and an infrastructure test documents the choice.browser.apicontracts. The Gutenberg Browser project and all 833 Storybook Browser tests pass..vitestis ignored for new failure artifacts.benchimport. The useful experiments are listed below.act()handling. jest-dom 7's Node and@testing-library/domrequirements are satisfied, and 7.0.1 declares Vitest as an optional peer. The flakiness patches correct Vitest stdio and.failsreporting. These changes affect tests and reporting only.The review also covered the complete Vitest migration guide and Vitest 5 release highlights.
Known compromise
@storybook/addon-vitest10.5.9 still declares Vitest 3/4 peers, sonpm lsreports the Vitest 5 packages as invalid. The clean install, production build, static Storybook build, and all 833 Storybook Browser tests pass with the unpatched addon. Removing it would remove Storybook's Vitest coverage, while a local metadata patch would only hide the warning. This PR keeps it unchanged while storybookjs/storybook#36221 adds upstream support.Performance
The same-head Node 24 comparison found no reproducible speed improvement. Four CI-shaped Node/jsdom shards were flat overall, and the three-run Storybook median was 0.4% slower. Vitest's shared-server optimization does not apply to Gutenberg's current project layout.
Measurements
Both versions used Node 24 and base commit
b21da9b2199.Follow-ups
Configuration, performance, and flake investigations
fsModuleCache. A warm-cache trial improved the median by about 4.7%, but worsened the mean, created about 93 MB of cache data, and does not support Browser Mode.jest-consolesubprocess timeout under CI-shaped contention. It reached the five-second limit during loaded full runs, but passed 20 isolated repetitions and the final complete run. Profile Jest startup before changing the test or timeout.injectCjsGlobals: false, Browser traces, and single-file HTML reports as separate hardening and diagnostics changes.Testing Instructions
npm ls vitest @vitest/browser @vitest/browser-playwright. The only invalid peers should be the documented Storybook addon ranges.Verified locally with a clean install, build, typecheck, dependency checks, 35,749 passing Vitest tests, and 833 passing Storybook Browser tests.
Testing Instructions for Keyboard
Not applicable. This PR changes development dependencies and test infrastructure only.
Use of AI Tools
Codex helped audit upstream releases and migration guidance, inspect consumers, implement the changes, run verification and performance comparisons, and draft this description. The author reviewed the changes and conclusions against the repository and official upstream sources.