molecule-core/canvas/package.json
Hongming Wang 57457899a1 feat(canvas): vitest coverage instrumentation (#1815, no CI gate yet)
[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>
2026-04-26 23:44:07 -07:00

48 lines
1.3 KiB
JSON

{
"name": "molecule-monorepo-canvas",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack -p 3000",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "vitest run",
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-tabs": "^1.1.12",
"@radix-ui/react-tooltip": "^1.1.14",
"@tailwindcss/typography": "^0.5.19",
"@xterm/addon-fit": "^0.11.0",
"@xyflow/react": "^12.4.0",
"clsx": "^2.1.1",
"next": "^15.1.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.5.0",
"xterm": "^5.3.0",
"zustand": "^5.0.0"
},
"devDependencies": {
"@playwright/test": "^1.59.1",
"@testing-library/jest-dom": "^6.6.0",
"@testing-library/react": "^16.1.0",
"@types/node": "^22.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@vitejs/plugin-react": "^6.0.1",
"@vitest/coverage-v8": "^4.1.5",
"autoprefixer": "^10.4.0",
"jsdom": "^25.0.0",
"postcss": "^8.4.0",
"tailwindcss": "^3.4.0",
"typescript": "^5.7.0",
"vitest": "^4.1.2"
}
}