Skip to content

Commit 2aef708

Browse files
authored
feat: use vitest v4 (#4219)
1 parent 1f314fa commit 2aef708

7 files changed

Lines changed: 266 additions & 284 deletions

File tree

.changeset/brave-seahorses-flow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ permissions:
1111
checks: write
1212
pull-requests: write
1313

14+
concurrency:
15+
group: test-${{ github.event.pull_request.number || github.run_id }}
16+
cancel-in-progress: true
17+
1418
jobs:
1519
test:
1620
name: Build & test

apps/storybook/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"@types/ramda": "^0.31.1",
3333
"@types/react": "^19.2.2",
3434
"@types/react-dom": "^19.2.2",
35-
"@vitest/browser": "3.2.4",
36-
"@vitest/coverage-v8": "3.2.4",
35+
"@vitest/browser": "4.0.7",
36+
"@vitest/coverage-v8": "4.0.7",
3737
"axe-playwright": "^2.2.2",
3838
"playwright": "^1.56.1",
3939
"prettier": "^3.6.2",
@@ -42,6 +42,6 @@
4242
"remark-gfm": "^4.0.1",
4343
"storybook": "^9.1.16",
4444
"storybook-addon-pseudo-states": "^9.1.16",
45-
"vitest": "3.2.4"
45+
"vitest": "4.0.7"
4646
}
4747
}

apps/storybook/vitest.config.ts

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import path from 'node:path';
22
import { fileURLToPath } from 'node:url';
33
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
4-
import { defineConfig, mergeConfig } from 'vitest/config';
4+
import { playwright } from '@vitest/browser-playwright';
5+
import { mergeConfig } from 'vitest/config';
56

67
import viteConfig from '../../vite.config';
78

@@ -10,41 +11,38 @@ const dirname =
1011
? __dirname
1112
: path.dirname(fileURLToPath(import.meta.url));
1213

13-
export default mergeConfig(
14-
viteConfig,
15-
defineConfig({
16-
plugins: [
17-
storybookTest({
18-
configDir: path.join(dirname, '.storybook'),
19-
storybookScript: 'pnpm dev --ci',
20-
}),
21-
],
22-
test: {
23-
exclude: ['./../../packages/**/*.chromatic.tsx', './../../**/*.mdx'],
24-
watch: false,
25-
browser: {
26-
enabled: true,
27-
instances: [{ browser: 'chromium' }],
28-
provider: 'playwright',
29-
headless: true,
30-
},
31-
setupFiles: ['./.storybook/vitest.setup.ts'],
32-
reporters: [
33-
'default',
34-
[
35-
'junit',
36-
{
37-
outputFile: 'test-report.xml',
38-
suiteName: 'Storybook tests',
39-
addFileAttribute: true,
40-
classnameTemplate: (vars: {
41-
filename: string;
42-
filepath: string;
43-
}): string =>
44-
vars.filename.split('../../packages/react/')[1] ?? vars.filename,
45-
},
46-
],
47-
],
14+
export default mergeConfig(viteConfig, {
15+
plugins: [
16+
storybookTest({
17+
configDir: path.join(dirname, '.storybook'),
18+
storybookScript: 'pnpm dev --ci',
19+
}),
20+
],
21+
test: {
22+
exclude: ['./../../packages/**/*.chromatic.tsx', './../../**/*.mdx'],
23+
watch: false,
24+
browser: {
25+
enabled: true,
26+
instances: [{ browser: 'chromium' }],
27+
provider: playwright(),
28+
headless: true,
4829
},
49-
}),
50-
);
30+
setupFiles: ['./.storybook/vitest.setup.ts'],
31+
reporters: [
32+
'default',
33+
[
34+
'junit',
35+
{
36+
outputFile: 'test-report.xml',
37+
suiteName: 'Storybook tests',
38+
addFileAttribute: true,
39+
classnameTemplate: (vars: {
40+
filename: string;
41+
filepath: string;
42+
}): string =>
43+
vars.filename.split('../../packages/react/')[1] ?? vars.filename,
44+
},
45+
],
46+
],
47+
},
48+
});

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@
4141
"@testing-library/jest-dom": "^6.9.1",
4242
"@types/node": "^22.19.0",
4343
"@vitejs/plugin-react-swc": "^4.2.0",
44-
"@vitest/coverage-v8": "3.2.4",
45-
"@vitest/ui": "3.2.4",
44+
"@vitest/coverage-v8": "4.0.7",
45+
"@vitest/browser-playwright": "4.0.7",
46+
"@vitest/ui": "4.0.7",
4647
"chromatic": "^13.3.3",
4748
"just-pnpm": "^1.0.2",
4849
"tsconfck": "^3.1.6",
4950
"typescript": "^5.9.3",
5051
"typescript-plugin-css-modules": "^5.2.0",
5152
"vite": "^7.1.12",
52-
"vitest": "3.2.4"
53+
"vitest": "4.0.7"
5354
}
5455
}

packages/react/vitest.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { resolve } from 'node:path';
2+
import { playwright } from '@vitest/browser-playwright';
23
import { parse } from 'tsconfck';
34
/// <reference types="vitest" />
45
import { defineProject } from 'vitest/config';
@@ -28,7 +29,7 @@ export default defineProject({
2829
browser: {
2930
enabled: true,
3031
instances: [{ browser: 'chromium' }],
31-
provider: 'playwright',
32+
provider: playwright(),
3233
headless: true,
3334
},
3435
},

0 commit comments

Comments
 (0)