forked from molecule-ai/molecule-core
[Molecule-Platform-Evolvement-Manager] Closes step 1+2 of #1815. Step 3 (CI gate + threshold) is split into a follow-up because today's baseline is ~46% lines / ~45% statements, not the 70% the issue's draft thresholds assumed. ## What this lands - `canvas/vitest.config.ts` — `coverage` block with v8 provider, reporters: text (terminal) / html (./coverage/index.html) / json-summary (machine-readable for tooling). NO threshold — pure observability. - `canvas/package.json` — adds `test:coverage` script (`vitest run --coverage`); existing `test` script is unchanged so the default workflow is identical. - `canvas/package-lock.json` — adds @vitest/coverage-v8@^4.1.5 (the v8 provider Vitest uses for native coverage). ## Why no threshold yet Issue draft threshold was 70%/70%/65%/70% (lines/funcs/branches/stmts). Local baseline today: ``` Statements : 45.19% (3248/7186) Branches : 39.87% (2034/5101) Functions : 40.99% (724/1766) Lines : 46.36% (2905/6265) ``` Turning on a 70% gate today would either fail CI immediately or get papered over with an ad-hoc exclude list. Better path: land observability now, run coverage in PR review for any new code (via the new script), gate later when the baseline catches up. ## Heatmap (from local run, top gaps) - `src/lib/runtime-names.ts` — 0% (untouched by tests) - `src/lib/utils.ts` — 0% - `src/lib/canvas-actions.ts` — 25% - `src/store/classNames.ts` — 17% - `src/store/canvas.ts` — 73% (already-tested but the largest absolute gap by lines) Each is a concrete follow-up issue / PR target. ## Test plan - [x] `npx vitest run --coverage` runs cleanly locally (~10s) and produces `./coverage/index.html` + a `coverage-summary.json` - [x] Existing `npm run test` workflow unchanged — instrumentation only activates with `--coverage` flag - [x] No production-code changes — pure tooling addition ## Follow-ups (each tracked separately; this PR keeps minimal scope) - Step 3a — write tests for the 0% files above (~tiny each) - Step 3b — once baseline ≥ thresholds, add `thresholds` block to vitest.config.ts + a `npm run test:coverage` step in `.github/workflows/ci.yml`'s Canvas job 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { defineConfig } from 'vitest/config'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
test: {
|
|
environment: 'node',
|
|
exclude: ['e2e/**', 'node_modules/**', '**/dist/**'],
|
|
// Coverage is instrumented but NOT yet a CI gate — first land
|
|
// observability so we can see the baseline, then dial in
|
|
// thresholds + a hard gate in a follow-up PR (#1815). Today's
|
|
// baseline is unknown; turning on a 70% threshold blind would
|
|
// either fail CI immediately or paper over a real gap with an
|
|
// ad-hoc exclude list.
|
|
//
|
|
// Run locally with: `npm run test:coverage`
|
|
// Reports: text (terminal), html (./coverage/index.html),
|
|
// json-summary (machine-readable for tooling).
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'html', 'json-summary'],
|
|
include: ['src/**/*.{ts,tsx}'],
|
|
exclude: [
|
|
'src/**/*.test.{ts,tsx}',
|
|
'src/**/__tests__/**',
|
|
'src/**/*.d.ts',
|
|
'src/types/**',
|
|
],
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
})
|