Skip to content

build(test)!: move JS tests from Jest to Vitest - #97

Open
Adi-ty wants to merge 1 commit into
mainfrom
build/vitest-migration
Open

Adi-ty wants to merge 1 commit into
mainfrom
build/vitest-migration

Conversation

@Adi-ty

@Adi-ty Adi-ty commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

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.

Fixes/Covers issue

Part of #58. Supersedes #84.

@Adi-ty

Adi-ty commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

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.

@Adi-ty
Adi-ty marked this pull request as ready for review November 19, 2026 20:19
Copilot AI balanced review requested due to automatic review settings November 19, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants