Skip to content

Commit 30db208

Browse files
Added test coverage statistics
1 parent cca7a90 commit 30db208

File tree

6 files changed

+208
-5
lines changed

6 files changed

+208
-5
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ concurrency:
1818
jobs:
1919
unit-test:
2020
runs-on: ubuntu-latest
21+
permissions:
22+
# Required to checkout the code
23+
# contents: read
24+
# Required to put a comment into the pull-request
25+
pull-requests: write
2126
steps:
2227
- name: Checkout
2328
uses: actions/checkout@v6
@@ -30,4 +35,11 @@ jobs:
3035
- run: npm ci
3136

3237
- name: Run tests
33-
run: npm run test
38+
run: npm run test:coverage
39+
40+
- name: Report coverage
41+
# Ensure this step runs even if tests fail
42+
if: always()
43+
uses: davelosert/vitest-coverage-report-action@v2
44+
with:
45+
comment-on: commit

.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)