Skip to content

Commit 2463223

Browse files
Added test coverage statistics
1 parent cca7a90 commit 2463223

File tree

6 files changed

+201
-5
lines changed

6 files changed

+201
-5
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ jobs:
3030
- run: npm ci
3131

3232
- name: Run tests
33-
run: npm run test
33+
run: npm run test:coverage
34+
35+
- name: Report coverage
36+
# Ensure this step runs even if tests fail
37+
if: always()
38+
uses: davelosert/vitest-coverage-report-action@v2

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Logs
2-
logs
2+
/logs
33
*.log
44
npm-debug.log*
55
yarn-debug.log*
@@ -11,11 +11,14 @@ lerna-debug.log*
1111
node_modules
1212

1313
# Build artifacts
14-
dist
15-
dist-ssr
14+
/dist
15+
/dist-ssr
1616
*.local
1717
*.tsbuildinfo
1818

19+
# Test coverage artifacts
20+
/coverage
21+
1922
# Editor directories and files
2023
.vscode/*
2124
!.vscode/extensions.json

package-lock.json

Lines changed: 174 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"build": "tsc -b && vite build",
99
"lint": "eslint .",
1010
"preview": "vite preview",
11-
"test": "vitest"
11+
"test:unit": "vitest",
12+
"test:coverage": "vitest --coverage.enabled true"
1213
},
1314
"dependencies": {
1415
"@tailwindcss/vite": "^4.1.17",
@@ -22,6 +23,7 @@
2223
"@types/react": "^19.2.7",
2324
"@types/react-dom": "^19.2.3",
2425
"@vitejs/plugin-react": "^5.1.1",
26+
"@vitest/coverage-v8": "^4.0.16",
2527
"eslint": "^9.39.1",
2628
"eslint-plugin-react-hooks": "^7.0.1",
2729
"eslint-plugin-react-refresh": "^0.4.24",

src/vite.env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Transform SVGs into React components by importing them with the "?react" suffix
12
/// <reference types="vite-plugin-svgr/client" />
23

34
// Recognize all CSS files as module imports.

vitest.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
coverage: {
6+
include: ["src/**/*.{ts,tsx}"],
7+
reporter: ["text", "json-summary", "json"],
8+
reportOnFailure: true,
9+
},
10+
},
11+
});

0 commit comments

Comments
 (0)