Batch: https://github.com/github/primer/issues/5336
This issue tracks updating the KeybindingHint tests from Jest to Vitest. If you want to use Copilot for this, you can use the prompt below with either Agent mode locally or by assigning copilot to this issue directly.
Copilot instructions
We are moving our test suite from Jest to Vitest. We've migrated some test files already, you can use packages/react/src/Banner/Banner.test.tsx as an example. When migrating, make sure to:
- Update
packages/react/src/vitest.config.browser.mts to include the component that you're migrating in the include config
- Update
packages/react/src/jest.config.js to exclude the component that you're migrating in the modulePathIgnorePatterns config
- Remove any behavesAsComponent usage
- Remove any
checkExports usage
- Remove any tests that make axe assertions with toHaveNoViolations
- Remove any
setupMatchMedia usage
- Update tests that use
render from utils/testing to instead use render from @testing-library/react
- Use
npx vitest --run with the path to the test file you've updated to validate your changes
- You can update snapshots using
npx vitest --run -u with the path to the test file you would like to update snapshots for
- Do not migrate test files that are for types, these files end with
*.types.test.tsx
- If you run into a test that uses
it.skip, you can enable it now that we're moving to vitest
After migrating all components:
- Use
npx prettier --write with the path to the test files to format the file according to the prettier rules on the project
- Use
npx eslint with the path to the test files you've updated to make sure there are no eslint errors with your changes
Make sure to keep in mind:
- All
npx commands should be run from the root of the project
- Tests should not emit an
act() warning when updated
- Do not remove any tests when migrating
Batch: https://github.com/github/primer/issues/5336
This issue tracks updating the KeybindingHint tests from Jest to Vitest. If you want to use Copilot for this, you can use the prompt below with either Agent mode locally or by assigning copilot to this issue directly.
Copilot instructions
We are moving our test suite from Jest to Vitest. We've migrated some test files already, you can use packages/react/src/Banner/Banner.test.tsx as an example. When migrating, make sure to:
packages/react/src/vitest.config.browser.mtsto include the component that you're migrating in the include configpackages/react/src/jest.config.jsto exclude the component that you're migrating in the modulePathIgnorePatterns configcheckExportsusagesetupMatchMediausagerenderfrom utils/testing to instead use render from@testing-library/reactnpx vitest --runwith the path to the test file you've updated to validate your changesnpx vitest --run -uwith the path to the test file you would like to update snapshots for*.types.test.tsxit.skip, you can enable it now that we're moving to vitestAfter migrating all components:
npx prettier --writewith the path to the test files to format the file according to the prettier rules on the projectnpx eslintwith the path to the test files you've updated to make sure there are no eslint errors with your changesMake sure to keep in mind:
npxcommands should be run from the root of the projectact()warning when updated