Skip to content

Commit 1bc82dd

Browse files
authored
Merge pull request #29 from bartstc/chore/vitest-addon
chore: setup vitest addon
2 parents 3f0a66e + 44fa7f2 commit 1bc82dd

15 files changed

Lines changed: 538 additions & 4293 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ jobs:
5555
- name: Install dependencies
5656
run: pnpm install --no-frozen-lockfile --ignore-scripts
5757

58-
- name: Run coverage
59-
run: pnpm test:coverage
60-
6158
- name: Run unit tests
62-
run: pnpm test:ci
59+
run: pnpm test:unit:ci
6360

6461
- name: Upload test results
6562
if: success() || failure()
@@ -132,14 +129,8 @@ jobs:
132129
if: steps.playwright-cache.outputs.cache-hit != 'true'
133130
run: pnpm exec playwright install chromium --with-deps --only-shell
134131

135-
- name: Build Storybook
136-
run: pnpm build-storybook --quiet
137-
138-
- name: Serve Storybook and run tests
139-
run: |
140-
pnpm exec concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
141-
"pnpm exec http-server storybook-static --port 6006 --silent" \
142-
"pnpm exec wait-on tcp:6006 && pnpm exec test-storybook --coverage --coverageDirectory=coverage --excludeTags=\"!test\" --junit --outputFile reports/storybook-report.json"
132+
- name: Run storybook tests
133+
run: pnpm test:storybook:ci
143134

144135
- name: Upload test results
145136
if: success() || failure()

.storybook/main.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { AddonOptionsVite } from "@storybook/addon-coverage";
21
import type { StorybookConfig } from "@storybook/react-vite";
32
import * as tsconfigPaths from "vite-tsconfig-paths";
43

@@ -7,18 +6,9 @@ const config: StorybookConfig = {
76

87
addons: [
98
"@storybook/addon-links",
10-
"@storybook/addon-a11y",
119
"storybook-addon-remix-react-router",
12-
{
13-
name: "@storybook/addon-coverage",
14-
options: {
15-
istanbul: {
16-
include: ["src/**/*.tsx"],
17-
exclude: ["src/**/*.ts", "src/test-lib/*.tsx"],
18-
},
19-
} satisfies AddonOptionsVite,
20-
},
2110
"@storybook/addon-docs",
11+
"@storybook/addon-vitest",
2212
],
2313

2414
framework: {

.storybook/preview.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ export const parameters = {
1414
date: /Date$/,
1515
},
1616
},
17-
a11y: { disable: true },
17+
a11y: {
18+
disable: true,
19+
// 'todo' - show a11y violations in the test UI only
20+
// 'error' - fail CI on a11y violations
21+
// 'off' - skip a11y checks entirely
22+
test: "todo",
23+
},
1824
};
1925

2026
initialize(

.storybook/test-runner.ts

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

.storybook/vitest.setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { setProjectAnnotations } from "@storybook/react-vite";
2+
3+
import * as projectAnnotations from "./preview";
4+
5+
// This is an important step to apply the right configuration when testing your stories.
6+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7+
setProjectAnnotations([projectAnnotations]);

package.json

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"dev": "vite",
88
"build": "tsc && vite build",
99
"test": "vitest",
10-
"test:ci": "vitest run --reporter verbose --reporter=junit --outputFile=./reports/unit-report.xml --coverage --coverage.reporter=lcov --coverage.reportsDirectory=./coverage",
10+
"test:unit": "vitest --project=unit",
11+
"test:storybook": "vitest --project=storybook",
12+
"test:unit:ci": "vitest run --project=\"unit\" --reporter verbose --reporter=junit --outputFile=./reports/unit-report.xml --coverage --coverage.reporter=lcov --coverage.reportsDirectory=./coverage",
13+
"test:storybook:ci": "vitest run --project=\"storybook\" --reporter verbose --reporter=junit --outputFile=./reports/storybook-report.xml --coverage --coverage.reporter=lcov --coverage.reportsDirectory=./coverage",
1114
"test:coverage": "vitest run --coverage",
1215
"preview": "vite preview",
1316
"lint": "eslint . --ignore-pattern '*.d.ts' --report-unused-disable-directives --max-warnings 0",
1417
"prepare": "husky install",
15-
"storybook": "storybook dev -p 6006",
16-
"test-storybook": "test-storybook --watch",
17-
"test-storybook:coverage": "test-storybook --coverage",
18-
"build-storybook": "storybook build --test"
18+
"storybook": "storybook dev -p 6006"
1919
},
2020
"dependencies": {
2121
"@chakra-ui/icons": "2.1.1",
@@ -31,7 +31,7 @@
3131
"i18next-localstorage-backend": "4.2.0",
3232
"ky": "0.33.3",
3333
"query-string": "8.2.0",
34-
"ramda": "^0.31.3",
34+
"ramda": "0.31.3",
3535
"react": "19.1.0",
3636
"react-dom": "19.1.0",
3737
"react-error-boundary": "3.1.4",
@@ -41,22 +41,19 @@
4141
},
4242
"devDependencies": {
4343
"@eslint/js": "9.24.0",
44-
"@storybook/addon-a11y": "9.0.15",
45-
"@storybook/addon-coverage": "2.0.0",
46-
"@storybook/addon-docs": "9.0.15",
47-
"@storybook/addon-links": "9.0.15",
48-
"@storybook/react-vite": "9.0.15",
49-
"@storybook/test-runner": "0.23.0",
44+
"@storybook/addon-docs": "9.0.18",
45+
"@storybook/addon-links": "9.0.18",
46+
"@storybook/addon-vitest": "9.0.18",
47+
"@storybook/react-vite": "9.0.18",
5048
"@testing-library/jest-dom": "6.6.3",
5149
"@testing-library/react": "16.0.0",
52-
"@types/ramda": "^0.30.2",
50+
"@types/ramda": "0.30.2",
5351
"@types/react": "19.1.8",
5452
"@types/react-dom": "19.1.6",
5553
"@types/testing-library__jest-dom": "5.14.9",
5654
"@vitejs/plugin-react-swc": "3.10.2",
55+
"@vitest/browser": "3.2.4",
5756
"@vitest/coverage-istanbul": "3.2.4",
58-
"axe-playwright": "2.1.0",
59-
"concurrently": "8.2.0",
6057
"eslint": "9.24.0",
6158
"eslint-config-prettier": "10.1.2",
6259
"eslint-import-resolver-typescript": "4.3.2",
@@ -65,25 +62,23 @@
6562
"eslint-plugin-react": "7.37.5",
6663
"eslint-plugin-react-hooks": "5.2.0",
6764
"eslint-plugin-react-refresh": "0.4.19",
68-
"eslint-plugin-storybook": "9.0.15",
65+
"eslint-plugin-storybook": "9.0.18",
6966
"eslint-plugin-vitest": "0.5.4",
70-
"http-server": "14.1.1",
7167
"husky": "8.0.3",
7268
"jsdom": "21.1.2",
73-
"msw": "2.7.3",
74-
"msw-storybook-addon": "2.0.4",
69+
"msw": "2.10.4",
70+
"msw-storybook-addon": "^2.0.5",
7571
"playwright": "1.52.0",
7672
"prettier": "3.5.3",
7773
"pretty-quick": "4.1.1",
78-
"storybook": "9.0.15",
74+
"storybook": "9.0.18",
7975
"storybook-addon-remix-react-router": "5.0.0",
8076
"typescript": "5.8.2",
8177
"typescript-eslint": "8.30.1",
8278
"vite": "7.0.5",
8379
"vite-plugin-checker": "0.10.1",
8480
"vite-tsconfig-paths": "5.1.4",
85-
"vitest": "3.2.4",
86-
"wait-on": "7.2.0"
81+
"vitest": "3.2.4"
8782
},
8883
"browserslist": {
8984
"production": [

0 commit comments

Comments
 (0)