Repository navigation
Conversation
🤖 PR meta 🤖📦 Bundle sizeSize Change: 0 B Total Size: 8.08 MB
⚡ 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
|
|
@WordPress/gutenberg-components @tyxla @manzoorwanijk @Mamaduka @t-hamano @sirreal @desrosj As I started working on a vitest replacement for existing Compared to Jest, most features are already available in Vitest. The useful additions could start as tested configuration examples and a small internal console helper. Existing Jest packages do not require one-for-one Vitest replacements. The main tradeoff is consistent configuration and centrally distributed fixes versus additional maintenance. Shared packages could help WordPress projects, but upstream Vitest/Vite changes can require updates to configuration, matcher types, supported versions and consumer tests, followed by new releases. We already needed different Vite 7/8 optimizer settings and Vitest 5 matcher types. Copied configurations shift that maintenance to consumers; they do not eliminate it. Preset: which features are worth keeping?“Supported” does not always mean “enabled by default.” Several useful policies only need native configuration options.
Removing a dependency from Gutenberg later would not automatically remove the obligation to support external consumers who rely on it through a public preset. Console: useful enforcement, but reconsider the inherited APIFailing tests on unexpected warnings/errors is worth keeping. Vitest's normal spies can assert expected calls, but do not automatically enforce that policy across a suite. Custom names such as The current helper also has a weakness: once a test acknowledges one warning, an additional unexpected warning can pass. A replacement should consider checking the complete expected call list. We should also decide whether We compared the following on Vitest 5 in Node, jsdom and Chromium:
Global console spies also remain unsafe for concurrent tests within one file. File isolation alone does not solve that problem. Verification and a possible next stepA small configuration using neither proposed package passed representative Node, jsdom and Chromium tests on Vite 7 and 8, including JSX and both generated CSS output forms. This was not a full Gutenberg migration or a finished replacement configuration. The current packages also passed all six supported Node/Vite consumer combinations. That establishes that they work, but does not establish that publishing them is necessary. I'd start with tested config examples, keep Gutenberg's shared setup internal, and refine console enforcement separately. If external projects need the same maintained conventions, we could then consider a small public config export or helper with a clear scope. Neither package is currently required by Gutenberg's internal migration. Existing public Jest tooling and Let me know what y'all think ✌️ |
|
IMHO, it's fine to deprecate them and announce the move to Vitest. |
|
Cool, I'm going to close this PR and skip this step in the migration. Thank you all |
| '[Tool] Vitest console': | ||
| - changed-files: | ||
| - any-glob-to-any-file: 'packages/vitest-console/**' | ||
|
|
||
| '[Tool] Vitest preset': | ||
| - changed-files: | ||
| - any-glob-to-any-file: 'packages/vitest-preset-default/**' | ||
|
|
There was a problem hiding this comment.
Observation: My validation changes in #76263 were effective in making sure that new packages are added to the mapping here, though I suppose it doesn't actually validate that the label actually exists, which might be a good follow-on enhancement.
It looks like @sirreal 's improvements in #81614 might help this.
This is pretty valuable testimony in itself to a benefit of adopting Vitest 🙌 |
Part of #80855. Follows #82761 and uses the build guard merged in #82154.
What?
Add
@wordpress/vitest-consoleand@wordpress/vitest-preset-defaultfor Vitest 5, with public exports, matcher types, package registration, changelogs and migration guidance. Prepare their additive release.Why?
The replacement packages must ship and pass consumer verification before released tooling adopts them. Existing Jest packages, Jest lint defaults and
wp-scripts test-unit-jsremain available.How?
The preset uses Node by default, filename-selected jsdom and Chromium projects, explicit imports and isolated tests. Node/jsdom use CSS proxies; Browser Mode loads real styles and preserves native browser APIs. Consumer setup runs after preset setup. Plain React JSX works without Emotion installed. Consumers install and configure the Emotion transform explicitly on Vite 7 and 8.
Add isolated packed-consumer checks and a separate public Node/Vite CI matrix. The existing repository test matrix is unchanged.
Testing Instructions
npm run --workspace @wordpress/unit-tests test:unit:vitest:packages.VITEST_CONSUMER_VITE=7.3.6to check Vite 7. SetVITEST_CONSUMER_JEST=1on Node 24 to include the unchanged packed Jest tooling.*.jsdom.test.*should use jsdom, and*.browser.test.*should use Chromium with real styles.Verification and release notes
351883676c6: 5 low, 27 moderate and 15 high.vitest/configdeclaration entry references the undeclared@vitest/expectpackage. The documented.mjsconfig works; this preset's public types useviteandvitest/nodeand compile without that retired package.351883676c606bdefc0a8b4fd140833511ec03c1.Testing Instructions for Keyboard
Not applicable; this changes test tooling.
Follow-ups
Publish and verify
@wordpress/vitest-console, then@wordpress/vitest-preset-default, before adopting them in released public tooling. The packages use the repository's1.0.0-prereleaseconvention until release processing.Published
@wordpress/build@0.23.0contains the required guard. Rebuild affected generated CSS with that version or later. No additional build-fix PR is planned. Publishing these packages does not require switchingwp-scriptsor removing Jest.Use of AI Tools
Codex implemented the changes, ran verification and performed an independent review.