Skip to content

Commit 2b4514c

Browse files
toddaheathclaude
andcommitted
Add frontend test coverage with @vitest/coverage-v8
Configure vitest coverage with v8 provider and cobertura reporter. Add coverage step to CI pipeline that uploads coverage artifact. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a491229 commit 2b4514c

File tree

4 files changed

+165
-2
lines changed

4 files changed

+165
-2
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,16 @@ jobs:
9898
- name: TypeScript check
9999
run: npx tsc --noEmit
100100

101-
- name: Test
102-
run: npm test
101+
- name: Test with coverage
102+
run: npx vitest run --coverage
103+
104+
- name: Upload frontend coverage
105+
uses: actions/upload-artifact@v7
106+
if: always()
107+
with:
108+
name: frontend-coverage
109+
path: src/shed-builder-ui/coverage/coverage.cobertura.xml
110+
retention-days: 14
103111

104112
- name: Build
105113
run: npm run build

src/shed-builder-ui/package-lock.json

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

src/shed-builder-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@types/react-dom": "^19.2.3",
3434
"@types/three": "^0.182.0",
3535
"@vitejs/plugin-react": "^5.1.1",
36+
"@vitest/coverage-v8": "^4.0.18",
3637
"eslint": "^9.39.1",
3738
"eslint-plugin-react-hooks": "^7.0.1",
3839
"eslint-plugin-react-refresh": "^0.5.2",

src/shed-builder-ui/vitest.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ export default defineConfig({
77
environment: 'happy-dom',
88
setupFiles: ['./src/test-setup.ts'],
99
globals: true,
10+
coverage: {
11+
provider: 'v8',
12+
reporter: ['text', 'cobertura'],
13+
include: ['src/**/*.{ts,tsx}'],
14+
exclude: ['src/**/*.test.*', 'src/test-setup.ts', 'src/vite-env.d.ts'],
15+
},
1016
},
1117
})

0 commit comments

Comments
 (0)