refactor(project): remove support for jest#6452
Conversation
|
|
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
There was a problem hiding this comment.
Pull Request Overview
This PR completes the migration from Jest to Vitest as the default test runner for the Primer React project. The key changes focus on removing Jest-specific dependencies, configuration files, and updating test files to use Vitest APIs.
- Remove Jest configuration files and dependencies
- Update test files to use Vitest imports and APIs instead of Jest
- Clean up migration tracking workflow and scripts
- Update documentation to reference Vitest instead of Jest
Reviewed Changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/ToggleSwitch/__snapshots__/ToggleSwitch.test.tsx.snap |
Remove Jest snapshot file (entire file deleted) |
script/vitest-migration-status.mts |
Remove migration tracking script (entire file deleted) |
packages/react/vitest.config.browser.mts |
Simplify test inclusion patterns and add exclusions |
packages/react/src/utils/testing.tsx |
Remove Jest-specific testing utilities (entire file deleted) |
packages/react/src/utils/test-matchers.tsx |
Remove Jest-specific test matchers (entire file deleted) |
packages/react/src/utils/test-helpers.tsx |
Add TypeScript suppression comment |
packages/react/src/utils/test-deprecations.tsx |
Remove Jest-specific deprecation handling (entire file deleted) |
packages/react/src/experimental/UnderlinePanels/UnderlinePanels.test.tsx |
Update to use Vitest imports and mock functions |
packages/react/src/__tests__/BaseStyles.test.tsx |
Add type assertions for style expectations |
packages/react/src/Overlay/Overlay.test.tsx |
Fix style assertion value types |
packages/react/src/Dialog/Dialog.test.tsx |
Remove Jest-specific matchmedia mock setup |
packages/react/src/DataTable/__tests__/DataTable.test.tsx |
Add type assertion for style expectation |
packages/react/src/ActionList/ActionList.test.tsx |
Remove axe accessibility test and unused imports |
packages/react/package.json |
Remove Jest-related dependencies |
packages/react/jest.config.js |
Remove Jest configuration file (entire file deleted) |
packages/postcss-preset-primer/package.json |
Remove Babel and Jest dependencies |
packages/postcss-preset-primer/config/transform/jsTransform.js |
Remove Babel Jest transformer (entire file deleted) |
package.json |
Update root package.json to use Vitest commands and remove Jest dependencies |
eslint.config.mjs |
Remove Jest ESLint plugin configuration |
contributor-docs/testing.md |
Update documentation to reference Vitest instead of Jest |
contributor-docs/CONTRIBUTING.md |
Update technology stack reference from Jest to Vitest |
.github/workflows/migration-status.yml |
Remove Vitest migration tracking workflow |
.github/workflows/ci.yml |
Update CI workflow to use single test command |
| // @ts-nocheck | ||
| import {TextEncoder} from 'node:util' | ||
|
|
||
| // JSDOM doesn't mock ResizeObserver |
There was a problem hiding this comment.
The @ts-nocheck directive suppresses all TypeScript checking for this file. This is generally discouraged as it bypasses type safety. Consider either fixing the TypeScript issues or using more specific suppressions like @ts-expect-error or @ts-ignore for individual problematic lines.
| // JSDOM doesn't mock ResizeObserver | |
| import {TextEncoder} from 'node:util' | |
| // JSDOM doesn't mock ResizeObserver | |
| // @ts-expect-error: ResizeObserver is not defined in Node.js global types |
|
|
||
| it('throws an error when the number of tabs does not match the number of panels', () => { | ||
| const spy = jest.spyOn(console, 'error').mockImplementation() | ||
| const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) |
There was a problem hiding this comment.
The mock implementation for console.error should use a named function or store the original implementation to restore it properly. Consider using mockImplementation(vi.fn()) or storing the original function for better test isolation.
| const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) | |
| const spy = vi.spyOn(console, 'error').mockImplementation(vi.fn()) |
Closes https://github.com/github/primer/issues/5336
Removes Jest from the project in favor of Vitest now that our migration is complete 🫡
Changelog
New
Changed
Removed