-
Notifications
You must be signed in to change notification settings - Fork 3
test: Set up Vitest #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Set up Vitest #131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR sets up an automated JavaScript testing environment using Vitest instead of Jest for the Gutenberg project. The key changes include adding Vitest configuration files (vitest.setup.js and vitest.config.js), updating test files (editor-load-notice.test.jsx) to work with Vitest, and modifying build scripts (package.json, Makefile, and Buildkite pipeline) and documentation to support JavaScript tests.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
vitest.setup.js | Configures auto-cleanup for tests using Testing Library with Vitest. |
vitest.config.js | Defines the Vitest configuration including plugins and setup files. |
src/components/editor-load-notice.test.jsx | Adds tests for EditorLoadNotice covering multiple user interactions. |
package.json | Updates scripts and dependencies to include Vitest and Testing Library. |
mocks/@wordpress/i18n/index.js | Provides a simple mock for i18n functions using Vitest’s vi.fn(). |
mocks/@wordpress/components/index.jsx | Mocks a Notice component for testing purposes. |
README.md | Enhances documentation with instructions for running JavaScript and other tests. |
Makefile | Adds a target to run JavaScript tests via npm and Vitest. |
.buildkite/pipeline.yml | Introduces a step to run JavaScript tests on the CI pipeline. |
Avoid cryptic errors from lingering global stubs.
What?
Set up an automated JavaScript testing environment.
Why?
Improve project stability. Close CMM-285.
How?
Leverage several dependencies already used by the Gutenberg project, with one divergence—use Vitest rather than Jest.
Attempts to set up an environment with
vitest-jest
and Gutenberg'sjest-preset-default
were unsuccessful, as I encountered numerous build errors related to Babel configuration. Using Jest, Vite, andjest-preset-default
together may not straightforward. Also,vitest-jest
appears to be an abandoned project. Vitest does have differences from Jest, but remains largely compatible.In the future, we could reengage explorations for how we might further align with Gutenberg and use
jest-preset-default
.Testing Instructions
N/A, no user-facing changes.
Accessibility Testing Instructions
N/A, no user-facing changes.
Screenshots or screencast
N/A, no user-facing changes.