Skip to content

Commit 52fff13

Browse files
authored
refactor(project): remove support for jest (#6452)
1 parent 08bf772 commit 52fff13

File tree

28 files changed

+9852
-15719
lines changed

28 files changed

+9852
-15719
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ jobs:
7272
run: npm ci
7373
- name: Build
7474
run: npm run build
75-
- name: Test
76-
run: npm run test -- --coverage
7775
- name: Run tests defined in vitest
7876
uses: docker://mcr.microsoft.com/playwright:v1.53.2-jammy
7977
with:
80-
args: npx vitest
78+
args: npm test
8179

8280
type-check:
8381
runs-on: ubuntu-latest

.github/workflows/migration-status.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,3 @@ jobs:
3434
- name: Run migration script
3535
run: |
3636
node --experimental-strip-types script/styled-components-migration-status.mts >> $GITHUB_STEP_SUMMARY
37-
38-
vitest:
39-
runs-on: ubuntu-latest
40-
steps:
41-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
42-
- name: Set up Node.js
43-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
44-
with:
45-
node-version: 22
46-
cache: 'npm'
47-
- name: Install dependencies
48-
run: npm ci
49-
- name: Run migration script
50-
run: |
51-
node --experimental-strip-types script/vitest-migration-status.mts >> $GITHUB_STEP_SUMMARY

contributor-docs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Navigate to http://localhost:6006/ to see Primer react components in your browse
6868

6969
- [React](https://reactjs.org/)
7070
- [TypeScript](https://www.typescriptlang.org/)
71-
- [Jest](https://jestjs.io/)
71+
- [Vitest](https://vitest.dev/)
7272
- [Storybook](https://storybook.js.org/)
7373
- [Prettier](https://prettier.io/)
7474
- [ESLint](https://eslint.org/)

contributor-docs/testing.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ We make sure that every component has [these fundamental unit tests](https://git
6161

6262
### Overview
6363

64-
We use [Jest](https://jestjs.io/) as our test runner to write and run our unit tests. Our preferred way of structuring tests is with `describe/it` block format and they are authored within the components's source directory with the file name of `ComponentName.test.tsx`
64+
We use [Vitest](https://vitest.dev/) as our test runner to write and run our unit tests. Our preferred way of structuring tests is with `describe/it` block format and they are authored within the components's source directory with the file name of `ComponentName.test.tsx`
6565

6666
We predominantly use [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/)'s testing helpers such as
6767

@@ -70,22 +70,20 @@ We predominantly use [@testing-library/react](https://testing-library.com/docs/r
7070
- `screen`
7171
- `act`
7272

73-
To make assertions about the elements we use [Jest](https://jestjs.io/) and [jest-dom](https://github.com/testing-library/jest-dom).
73+
To make assertions about the elements we use [Vitest](https://vitest.dev/) and [jest-dom](https://github.com/testing-library/jest-dom).
7474

7575
\*: Read about the [differences between `fireEvent` and `UserEvent`](https://testing-library.com/docs/user-event/intro/#differences-from-fireevent).
7676

7777
### Snapshots
7878

79-
We are slowly moving away from using `Jest` snapshots as a way to test visual changes of our components. You can read more about the decision in this [ADR](https://github.com/primer/react/blob/main/contributor-docs/adrs/adr-011-snapshot-tests.md). We are in the process of migrating our existing snapshot tests to use [Playwright](https://playwright.dev/) for visual regression testing. If you are writing a new test and you need to test the visual changes of the component, please refer to the [Visual Regression Tests](#visual-regression-tests) section.
79+
We are slowly moving away from using snapshots as a way to test visual changes of our components. You can read more about the decision in this [ADR](https://github.com/primer/react/blob/main/contributor-docs/adrs/adr-011-snapshot-tests.md). We are in the process of migrating our existing snapshot tests to use [Playwright](https://playwright.dev/) for visual regression testing. If you are writing a new test and you need to test the visual changes of the component, please refer to the [Visual Regression Tests](#visual-regression-tests) section.
8080

8181
### Running Tests
8282

8383
| Task | Command |
8484
| :------------------ | :----------------------- |
8585
| Run unit tests | `npm test` |
8686
| Run a specific test | `npm test ComponentName` |
87-
| Debug unit tests | `npm test -- --watch` |
88-
| Unit test coverage | `npm test -- --coverage` |
8987
| Update snapshots | `npm test -- -u` |
9088

9189
## Interaction Tests

eslint.config.mjs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import eslintReact from '@eslint-react/eslint-plugin'
77
import vitest from '@vitest/eslint-plugin'
88
import {defineConfig, globalIgnores} from 'eslint/config'
99
import githubPlugin from 'eslint-plugin-github'
10-
import jest from 'eslint-plugin-jest'
1110
import storybook from 'eslint-plugin-storybook'
1211
import react from 'eslint-plugin-react'
1312
import reactCompiler from 'eslint-plugin-react-compiler'
@@ -132,7 +131,6 @@ const config = defineConfig([
132131
globals: {
133132
...globals.browser,
134133
...globals.commonjs,
135-
...globals.jest,
136134
...globals.node,
137135
__DEV__: 'readonly',
138136
},
@@ -266,25 +264,6 @@ const config = defineConfig([
266264
'@eslint-react/no-useless-forward-ref': 'off',
267265
},
268266
},
269-
// eslint-plugin-jest
270-
{
271-
files: ['**/*.test.{ts,tsx}'],
272-
ignores: ['**/e2e/**'],
273-
plugins: {
274-
jest,
275-
['testing-library']: testingLibrary,
276-
},
277-
languageOptions: {
278-
globals: jest.environments.globals.globals,
279-
},
280-
...jest.configs['flat/recommended'],
281-
rules: {
282-
...jest.configs['flat/recommended'].rules,
283-
'jest/expect-expect': 'off',
284-
'jest/no-conditional-expect': 'off',
285-
'jest/no-disabled-tests': 'off',
286-
},
287-
},
288267

289268
// eslint-plugin-vitest
290269
{

jest.config.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)