Skip to content

Commit 39c72fd

Browse files
ci(cov): report coverage on PR
1 parent 96ef4a6 commit 39c72fd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
- name: restore dependencies
4040
uses: bahmutov/npm-install@v1
4141
- run: npm run test
42+
- name: report coverage
43+
if: always()
44+
uses: davelosert/vitest-coverage-report-action@v2
4245
e2e:
4346
timeout-minutes: 60
4447
runs-on: ubuntu-latest

vite.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@ import { configDefaults } from 'vitest/config'
44

55
export default defineConfig({
66
test: {
7-
exclude: [...configDefaults.exclude, 'e2e', 'examples'],
7+
dir: 'src',
88
coverage: {
9+
enabled: true,
910
include: ['src'],
10-
enabled: true
11+
// defaults https://vitest.dev/guide/coverage.html#coverage-setup
12+
// the json-summary and json reporters are for reporting in PR
13+
// https://github.com/marketplace/actions/vitest-coverage-report#usage
14+
reporter: [
15+
...(configDefaults.coverage.reporter ?? []),
16+
'json-summary',
17+
'json'
18+
],
19+
// So we get coverage reports even if tests fail
20+
reportOnFailure: true
1121
}
1222
}
1323
})

0 commit comments

Comments
 (0)