Problem
vitest.config.ts runs coverage with @vitest/coverage-v8, but there are no coverage thresholds configured. The CI workflow (ci-and-labels.yml) does not fail on low coverage, meaning regressions can silently reduce test coverage. There is no coverage badge in the README.
Current State
// vitest.config.ts - coverage section (approximate)
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'json'],
// No thresholds configured!
}
# CI workflow - no coverage threshold step
- run: npm run test:coverage
# Missing: fail if below threshold, upload to Codecov
Proposed Changes
1. Add coverage thresholds to vitest.config.ts
export default defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'json', 'lcov'],
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.d.ts',
'src/**/*.stories.{ts,tsx}',
'src/vite-env.d.ts',
'src/main.tsx',
],
thresholds: {
lines: 60,
branches: 50,
functions: 60,
statements: 60,
// Per-file thresholds to prevent new files from having 0% coverage
perFile: true,
autoUpdate: false,
},
},
},
});
2. Update CI workflow
# .github/workflows/ci-and-labels.yml
- name: Run tests with coverage
run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: do-knowledge-studio
fail_ci_if_error: false
3. Add test:coverage script to package.json
"scripts": {
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:coverage:watch": "vitest --coverage"
}
4. Add coverage badge to README
<!-- README.md -->
[](https://codecov.io/gh/d-oit/do-knowledge-studio)
[](https://github.com/d-oit/do-knowledge-studio/actions/workflows/ci-and-labels.yml)
5. Add .codecov.yml configuration
# .codecov.yml
coverage:
status:
project:
default:
target: 60%
threshold: 5%
patch:
default:
target: 50%
threshold: 10%
comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false
Acceptance Criteria
Problem
vitest.config.tsruns coverage with@vitest/coverage-v8, but there are no coverage thresholds configured. The CI workflow (ci-and-labels.yml) does not fail on low coverage, meaning regressions can silently reduce test coverage. There is no coverage badge in the README.Current State
Proposed Changes
1. Add coverage thresholds to
vitest.config.ts2. Update CI workflow
3. Add
test:coveragescript topackage.json4. Add coverage badge to README
5. Add
.codecov.ymlconfigurationAcceptance Criteria
vitest.config.tshas coverage thresholds: lines 60%, branches 50%, functions 60%lcovreporter added for Codecov compatibilitytest:coveragescript inpackage.jsoncodecov/codecov-action@v4README.md.codecov.ymlwith project/patch coverage targetsCONTRIBUTING.md