Skip to content

Commit dd92291

Browse files
committed
test: migrate to vitest
1 parent 6cba8eb commit dd92291

28 files changed

+744
-2407
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
run: yarn --immutable
5353

5454
- name: Build and Test
55-
run: yarn run-s test-compiled test
55+
run: yarn run-s build test
5656

5757
- name: Lint
5858
run: yarn lint

Diff for: eslint.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import json from 'eslint-plugin-json'
99
import * as mdx from 'eslint-plugin-mdx'
1010
import n from 'eslint-plugin-n'
1111
import unicorn from 'eslint-plugin-unicorn'
12+
import vitest from 'eslint-plugin-vitest'
1213
import yml from 'eslint-plugin-yml'
1314
import prettier from 'eslint-plugin-prettier/recommended'
1415
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
@@ -108,6 +109,10 @@ export default config(
108109
'import-x/unambiguous': 'off',
109110
},
110111
},
112+
{
113+
files: ['test/**/*.spec.ts'],
114+
extends: [vitest.configs.recommended],
115+
},
111116
{
112117
files: ['**/*.ts'],
113118
rules: {
@@ -150,7 +155,7 @@ export default config(
150155
'**/*.d.ts',
151156
'**/.eslintrc.js',
152157
'eslint.config.js',
153-
'jest.config.ts',
158+
'vitest.config.ts',
154159
],
155160
rules: {
156161
'import-x/no-extraneous-dependencies': 'off',

Diff for: jest.config.ts

-29
This file was deleted.

Diff for: package.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@
6161
"lint:tsc": "tsc -p tsconfig.lib.json --noEmit",
6262
"prepare": "patch-package && simple-git-hooks && yarn-berry-deduplicate || exit 0",
6363
"release": "clean-pkg-json && changeset publish",
64-
"test": "node --experimental-vm-modules --no-warnings=ESLintRCWarning node_modules/jest/bin/jest.js",
65-
"test-compiled": "yarn build && TEST_COMPILED=1 yarn test",
64+
"test": "node --no-warnings=ESLintRCWarning node_modules/vitest/vitest.mjs --run",
6665
"update:eslint-docs": "eslint-doc-generator --rule-doc-title-format prefix-name --rule-doc-section-options false --rule-list-split meta.docs.category --ignore-config stage-0 --config-emoji recommended,☑️",
6766
"watch": "yarn test --watch"
6867
},
@@ -107,16 +106,12 @@
107106
"@eslint/import-test-order-redirect-scoped": "link:./test/fixtures/order-redirect-scoped",
108107
"@eslint/js": "^9.23.0",
109108
"@pkgr/rollup": "^6.0.1",
110-
"@swc-node/jest": "^1.8.13",
111-
"@swc/core": "^1.11.13",
112-
"@swc/helpers": "^0.5.15",
113109
"@test-scope/some-module": "link:./test/fixtures/symlinked-module",
114110
"@total-typescript/ts-reset": "^0.6.1",
115111
"@types/debug": "^4.1.12",
116112
"@types/eslint": "^9.6.1",
117113
"@types/eslint8.56": "npm:@types/eslint@~8.56.12",
118114
"@types/is-glob": "^4.0.4",
119-
"@types/jest": "^29.5.14",
120115
"@types/json-schema": "^7.0.15",
121116
"@types/klaw-sync": "^6.0.5",
122117
"@types/node": "^22.13.14",
@@ -134,18 +129,17 @@
134129
"eslint-import-test-order-redirect": "link:./test/fixtures/order-redirect",
135130
"eslint-plugin-eslint-plugin": "^6.4.0",
136131
"eslint-plugin-import-x": "link:.",
137-
"eslint-plugin-jest": "^28.11.0",
138132
"eslint-plugin-json": "^4.0.1",
139133
"eslint-plugin-mdx": "^3.3.1",
140134
"eslint-plugin-n": "^17.17.0",
141135
"eslint-plugin-prettier": "^5.2.5",
142136
"eslint-plugin-unicorn": "^58.0.0",
137+
"eslint-plugin-vitest": "^0.5.4",
143138
"eslint-plugin-yml": "^1.17.0",
144139
"eslint8.56": "npm:eslint@~8.56.0",
145140
"eslint9": "npm:eslint@^9.23.0",
146141
"globals": "^16.0.0",
147142
"hermes-eslint": "^0.27.0",
148-
"jest": "^30.0.0-alpha.7",
149143
"klaw-sync": "^7.0.0",
150144
"lint-staged": "^15.5.0",
151145
"npm-run-all2": "^7.0.2",
@@ -159,6 +153,7 @@
159153
"type-fest": "^4.38.0",
160154
"typescript": "^5.8.2",
161155
"typescript-eslint": "^8.28.0",
156+
"vitest": "^3.0.9",
162157
"yarn-berry-deduplicate": "^6.1.1",
163158
"zod": "^3.24.2"
164159
},

Diff for: patches/@swc-node+jest+1.8.13.patch

-20
This file was deleted.

Diff for: src/rules/no-unused-modules.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import path from 'node:path'
77

88
import { TSESTree } from '@typescript-eslint/utils'
99
import type { TSESLint } from '@typescript-eslint/utils'
10-
// eslint-disable-next-line import-x/default -- incorrect types , commonjs actually
10+
// eslint-disable-next-line import-x/default -- incorrect types, commonjs actually
1111
import eslintUnsupportedApi from 'eslint/use-at-your-own-risk'
1212

1313
import type { FileExtension, RuleContext } from '../types.js'
@@ -22,7 +22,7 @@ import {
2222
getValue,
2323
} from '../utils/index.js'
2424

25-
// eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
25+
// eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types, commonjs actually
2626
const { FileEnumerator } = eslintUnsupportedApi
2727

2828
function listFilesToProcess(src: string[], extensions: FileExtension[]) {

Diff for: test/__snapshots__/fixtures.spec.ts.snap

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`yarn pnp > should just work 1`] = `
4+
{
5+
"exitCode": 0,
6+
"stderr": "",
7+
"stdout": "",
8+
}
9+
`;
210

311
exports[`yarn pnp should just work 1`] = `
412
{

Diff for: test/__snapshots__/node-resolver.spec.ts.snap

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`builtin node:path => true 1`] = `
3+
exports[`builtin > node:path => true 1`] = `
44
{
55
"expected": true,
66
"requireResolve": "node:path",
77
"source": "node:path",
88
}
99
`;
1010

11-
exports[`builtin node:path => true 2`] = `
11+
exports[`builtin > node:path => true 2`] = `
1212
{
1313
"expected": true,
1414
"result": {
@@ -19,15 +19,15 @@ exports[`builtin node:path => true 2`] = `
1919
}
2020
`;
2121

22-
exports[`builtin path => true 1`] = `
22+
exports[`builtin > path => true 1`] = `
2323
{
2424
"expected": true,
2525
"requireResolve": "path",
2626
"source": "path",
2727
}
2828
`;
2929

30-
exports[`builtin path => true 2`] = `
30+
exports[`builtin > path => true 2`] = `
3131
{
3232
"expected": true,
3333
"result": {
@@ -38,15 +38,15 @@ exports[`builtin path => true 2`] = `
3838
}
3939
`;
4040

41-
exports[`modules @sukka/does-not-exists => false 1`] = `
41+
exports[`modules > @sukka/does-not-exists => false 1`] = `
4242
{
4343
"expected": false,
4444
"requireResolve": undefined,
4545
"source": "@sukka/does-not-exists",
4646
}
4747
`;
4848

49-
exports[`modules @sukka/does-not-exists => false 2`] = `
49+
exports[`modules > @sukka/does-not-exists => false 2`] = `
5050
{
5151
"expected": false,
5252
"result": {
@@ -56,34 +56,34 @@ exports[`modules @sukka/does-not-exists => false 2`] = `
5656
}
5757
`;
5858

59-
exports[`modules jest => true 1`] = `
59+
exports[`modules > vitest => true 1`] = `
6060
{
6161
"expected": true,
62-
"requireResolve": "<ROOT>/node_modules/jest/build/index.js",
63-
"source": "jest",
62+
"requireResolve": "<ROOT>/node_modules/vitest/index.cjs",
63+
"source": "vitest",
6464
}
6565
`;
6666

67-
exports[`modules jest => true 2`] = `
67+
exports[`modules > vitest => true 2`] = `
6868
{
6969
"expected": true,
7070
"result": {
7171
"found": true,
72-
"path": "<ROOT>/node_modules/jest/build/index.js",
72+
"path": "<ROOT>/node_modules/vitest/dist/index.js",
7373
},
74-
"source": "jest",
74+
"source": "vitest",
7575
}
7676
`;
7777

78-
exports[`relative ../.github/dependabot.yml => false 1`] = `
78+
exports[`relative > ../.github/dependabot.yml => false 1`] = `
7979
{
8080
"expected": false,
8181
"requireResolve": undefined,
8282
"source": "../.github/dependabot.yml",
8383
}
8484
`;
8585

86-
exports[`relative ../.github/dependabot.yml => false 2`] = `
86+
exports[`relative > ../.github/dependabot.yml => false 2`] = `
8787
{
8888
"expected": false,
8989
"result": {
@@ -93,15 +93,15 @@ exports[`relative ../.github/dependabot.yml => false 2`] = `
9393
}
9494
`;
9595

96-
exports[`relative ../babel.config.cjs => babel.config.cjs 1`] = `
96+
exports[`relative > ../babel.config.cjs => babel.config.cjs 1`] = `
9797
{
9898
"expected": "babel.config.cjs",
9999
"requireResolve": "<ROOT>/babel.config.cjs",
100100
"source": "../babel.config.cjs",
101101
}
102102
`;
103103

104-
exports[`relative ../babel.config.cjs => babel.config.cjs 2`] = `
104+
exports[`relative > ../babel.config.cjs => babel.config.cjs 2`] = `
105105
{
106106
"expected": "babel.config.cjs",
107107
"result": {
@@ -112,15 +112,15 @@ exports[`relative ../babel.config.cjs => babel.config.cjs 2`] = `
112112
}
113113
`;
114114

115-
exports[`relative ../inexistent.js => false 1`] = `
115+
exports[`relative > ../inexistent.js => false 1`] = `
116116
{
117117
"expected": false,
118118
"requireResolve": undefined,
119119
"source": "../inexistent.js",
120120
}
121121
`;
122122

123-
exports[`relative ../inexistent.js => false 2`] = `
123+
exports[`relative > ../inexistent.js => false 2`] = `
124124
{
125125
"expected": false,
126126
"result": {
@@ -130,15 +130,15 @@ exports[`relative ../inexistent.js => false 2`] = `
130130
}
131131
`;
132132

133-
exports[`relative ../package.json => package.json 1`] = `
133+
exports[`relative > ../package.json => package.json 1`] = `
134134
{
135135
"expected": "package.json",
136136
"requireResolve": "<ROOT>/package.json",
137137
"source": "../package.json",
138138
}
139139
`;
140140

141-
exports[`relative ../package.json => package.json 2`] = `
141+
exports[`relative > ../package.json => package.json 2`] = `
142142
{
143143
"expected": "package.json",
144144
"result": {
@@ -149,15 +149,15 @@ exports[`relative ../package.json => package.json 2`] = `
149149
}
150150
`;
151151

152-
exports[`relative ../test => test/index.js 1`] = `
152+
exports[`relative > ../test => test/index.js 1`] = `
153153
{
154154
"expected": "test/index.js",
155155
"requireResolve": "<ROOT>/test/index.js",
156156
"source": "../test",
157157
}
158158
`;
159159

160-
exports[`relative ../test => test/index.js 2`] = `
160+
exports[`relative > ../test => test/index.js 2`] = `
161161
{
162162
"expected": "test/index.js",
163163
"result": {
@@ -168,15 +168,15 @@ exports[`relative ../test => test/index.js 2`] = `
168168
}
169169
`;
170170

171-
exports[`relative ../test/ => test/index.js 1`] = `
171+
exports[`relative > ../test/ => test/index.js 1`] = `
172172
{
173173
"expected": "test/index.js",
174174
"requireResolve": "<ROOT>/test/index.js",
175175
"source": "../test/",
176176
}
177177
`;
178178

179-
exports[`relative ../test/ => test/index.js 2`] = `
179+
exports[`relative > ../test/ => test/index.js 2`] = `
180180
{
181181
"expected": "test/index.js",
182182
"result": {
@@ -187,15 +187,15 @@ exports[`relative ../test/ => test/index.js 2`] = `
187187
}
188188
`;
189189

190-
exports[`relative ../test/index.js => test/index.js 1`] = `
190+
exports[`relative > ../test/index.js => test/index.js 1`] = `
191191
{
192192
"expected": "test/index.js",
193193
"requireResolve": "<ROOT>/test/index.js",
194194
"source": "../test/index.js",
195195
}
196196
`;
197197

198-
exports[`relative ../test/index.js => test/index.js 2`] = `
198+
exports[`relative > ../test/index.js => test/index.js 2`] = `
199199
{
200200
"expected": "test/index.js",
201201
"result": {

0 commit comments

Comments
 (0)