You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
build(test)!: move JS tests from Jest to Vitest - #97
Moves the JavaScript tests from Jest to Vitest, the runner @wordpress/scripts 37 uses, and adds a React Testing Library test for the example block.
Technical Details
npm run test:js runs wp-scripts test-unit-js. vitest.config.mjs finds tests the way Gutenberg does (test/, __tests__/, *.test.*); *.jsdom.test.* files run in jsdom, the rest in Node.
Files containing JSX are now .jsx, including the create:block templates, since Vite parses JSX only there. create:block now refuses a slug whose folder already exists, so a rerun can't add an edit.jsx that shadows an existing edit.js.
The @wordpress/* packages are on one release and deduped: the tests load them from node_modules, where a second copy breaks block registration. Dependabot groups them, react/react-dom, and vitest/@vitest/*.
npm run test:js:coverage writes tests/logs/lcov.info.
@rtcamp/eslint-config 2 applies the Vitest lint rules to test files, and lint:js now covers tests/js.
test-measure.yml overrides the shared JS test command and cache, which pass Jest-only flags.
Breaking for generated plugins: block editor files are edit.jsx/save.jsx, and the Jest config and packages are gone.
Checklist
Replace Jest with Vitest and React Testing Library
Test the example block's saved markup and editor output
npm run test:js passes on an initialized plugin, with or without the examples
JS coverage report for wp-tooling's coverage gate
Follow-ups
None of these block this PR: CI passes with the override in test-measure.yml.
wp-tooling: update or drop wp/block-interactive's npm_dev_dependencies (@wordpress/block-editor ^16, blocks ^15, i18n ^6, interactivity ^6); installing them downgrades the editor packages and breaks the block tests.
Here, once that ships: set test-js-runner: vitest in test-measure.yml, drop test-js-command / test-js-cache, and list setup/vitest in .claude/skills/setup/SKILL.md.
Merging this needs a new @rtcamp/wp-tooling release. The published 2.0.0 only counts .js files as JS changes, so after this PR, a change to only .jsx or .mjs files (edit.jsx, save.jsx, *.jsdom.test.jsx, vitest.config.mjs) would skip Lint JS and Test JS. rtCamp/wp-tooling#80 fixes this on main, so this can merge once a release with it is on npm.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Moves the JavaScript tests from Jest to Vitest, the runner
@wordpress/scripts37 uses, and adds a React Testing Library test for the example block.Technical Details
npm run test:jsrunswp-scripts test-unit-js.vitest.config.mjsfinds tests the way Gutenberg does (test/,__tests__/,*.test.*);*.jsdom.test.*files run in jsdom, the rest in Node..jsx, including thecreate:blocktemplates, since Vite parses JSX only there.create:blocknow refuses a slug whose folder already exists, so a rerun can't add anedit.jsxthat shadows an existingedit.js.@wordpress/*packages are on one release and deduped: the tests load them fromnode_modules, where a second copy breaks block registration. Dependabot groups them,react/react-dom, andvitest/@vitest/*.npm run test:js:coveragewritestests/logs/lcov.info.@rtcamp/eslint-config2 applies the Vitest lint rules to test files, andlint:jsnow coverstests/js.test-measure.ymloverrides the shared JS test command and cache, which pass Jest-only flags.edit.jsx/save.jsx, and the Jest config and packages are gone.Checklist
npm run test:jspasses on an initialized plugin, with or without the examplesFollow-ups
None of these block this PR: CI passes with the override in
test-measure.yml.edit.jsx(fix(scaffolds): write block editor components to edit.jsx wp-tooling#107).setup/vitestscaffold, withsetup/jestdeprecated (feat(scaffolds): add setup/vitest and deprecate setup/jest wp-tooling#108).wp/block-interactive'snpm_dev_dependencies(@wordpress/block-editor ^16,blocks ^15,i18n ^6,interactivity ^6); installing them downgrades the editor packages and breaks the block tests.test-js-runner: jest | vitestinput onci-test-js.yml, forwarded bywp-ci.yml, so Vitest gets no Jest-only flags (--ci,--cacheDirectory) and the coverage step from feat: gate pull requests on changed-line coverage and report it wp-shared-workflows#66 passes Vitest's--coverage.*flags.test-js-runner: vitestintest-measure.yml, droptest-js-command/test-js-cache, and listsetup/vitestin.claude/skills/setup/SKILL.md.Fixes/Covers issue
Part of #58. Supersedes #84.