mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:21:10 +02:00
chore(ci): add v8 test coverage tracking (non-blocking baseline)
CI previously ran `pnpm run test || true` — test failures were silently
swallowed with no artifact, so we had no visibility into what was actually
passing across 1,296 test files.
- New `test:coverage` turbo pipeline task + root script; packages that opt
in by declaring their own `test:coverage` get picked up automatically.
- Wired up three high-value Vitest targets: apps/mana/apps/web (main
frontend, ~590 tests), shared-ui (Svelte component library), and
shared-storage (S3 client). Each emits lcov.info + coverage-summary.json
+ browsable HTML.
- apps/mana/apps/web `"test"` was running in watch mode (just `vitest`),
which hangs under turbo orchestration — changed to `vitest run` and
added `test:watch` for the interactive case.
- CI uploads coverage artifacts (14-day retention) regardless of whether
tests passed. `continue-on-error: true` replaces `|| true` so a failed
suite shows up as a warning annotation on the PR rather than being
invisible. Flip to a hard gate once main is green for a full week.
- Testing guideline documents the pattern + the template vitest config
+ the planned 80% threshold.
- ESLint flat-config `vitest.config.ts` ignore only matched at the root;
widened to `**/vitest.config.{ts,js,mjs}` so nested configs don't trip
the project-service parser.
Coverage baseline produced locally:
shared-storage: 91.37% lines (6 files, 123 tests)
shared-ui: 2.87% lines (mostly Svelte components, untested)
apps/mana/web: 9/59 test files fail — pre-existing, not regression
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1f589c474c
commit
4b8defcc4a
12 changed files with 447 additions and 219 deletions
|
|
@ -9,18 +9,61 @@
|
|||
| **SvelteKit Web** | Vitest | `vitest.config.ts` | `*.test.ts` |
|
||||
| **E2E** | Playwright | `playwright.config.ts` | `e2e/*.spec.ts` |
|
||||
|
||||
## Coverage Requirements
|
||||
## Coverage
|
||||
|
||||
```javascript
|
||||
// Target: 80% for all new code
|
||||
coverageThresholds: {
|
||||
global: {
|
||||
### Running coverage locally
|
||||
|
||||
```bash
|
||||
# From any Vitest package with a test:coverage script
|
||||
pnpm run test:coverage
|
||||
|
||||
# Across the whole monorepo (turbo orchestrates)
|
||||
pnpm run test:coverage
|
||||
```
|
||||
|
||||
Each package emits `coverage/` with:
|
||||
- `lcov.info` — consumed by CI artifact upload and external tools
|
||||
- `coverage-summary.json` — machine-readable totals
|
||||
- `lcov-report/` — browsable HTML report
|
||||
|
||||
### Vitest config template
|
||||
|
||||
Packages that need coverage add this block to `vitest.config.ts` and declare `@vitest/coverage-v8` as a devDep:
|
||||
|
||||
```ts
|
||||
test: {
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['text', 'lcov', 'json-summary'],
|
||||
reportsDirectory: './coverage',
|
||||
include: ['src/**/*.{ts,svelte}'],
|
||||
exclude: ['src/**/*.{test,spec}.ts', 'src/**/*.d.ts', 'src/**/index.ts'],
|
||||
},
|
||||
},
|
||||
```
|
||||
|
||||
Add a script:
|
||||
|
||||
```json
|
||||
"test:coverage": "vitest run --coverage"
|
||||
```
|
||||
|
||||
### CI
|
||||
|
||||
`.github/workflows/ci.yml` runs `pnpm run test:coverage` and uploads `**/coverage/lcov.info` + `coverage-summary.json` as an artifact (14-day retention). The step is currently non-blocking via `continue-on-error: true` — we are establishing a baseline before flipping to a hard-fail gate. Remove that flag once the suite is green on main.
|
||||
|
||||
### Targets (aspirational, not yet enforced)
|
||||
|
||||
```ts
|
||||
// Target once we flip coverage to blocking: 80% for all new code
|
||||
coverage: {
|
||||
thresholds: {
|
||||
lines: 80,
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
},
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
## Test File Organization
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue