mirror of
https://github.com/ankitects/anki.git
synced 2026-06-10 05:04:35 -04:00
## Linked issue Closes #4840 ## Summary / motivation Adds Vitest V8 coverage for TypeScript/Svelte tests via `@vitest/coverage-v8`. Introduces `just test-ts --coverage` and `just test-ts --coverage --html`, and wires TypeScript into the `just test --coverage` umbrella — completing coverage support across all three stacks (Python, Rust, TypeScript). The threshold is set to 5% — intentionally low because the Vitest test count is small relative to the TypeScript/Svelte source surface. It is meant to be raised as more tests are added. ## How to test ```sh # Existing behavior unchanged just test-ts # Terminal summary + enforces 5% line coverage threshold just test-ts --coverage # Terminal summary + HTML report under out/coverage/typescript/ just test-ts --coverage --html # Full umbrella — all three stacks just test --coverage just test --coverage --html ``` ### Checklist - [x] I ran `./ninja check` or an equivalent relevant check locally. ### Details - `@vitest/coverage-v8` pinned at `3.2.4` in `package.json`. - Reports are written to `out/coverage/typescript/` via `--coverage.reportsDirectory=../out/coverage/typescript` (relative to the `ts/` working directory where vitest runs). - V8 provider is preferred over Istanbul: faster and requires no Babel transform for TypeScript projects. - Coverage measures only code reachable through Vitest's module graph — Svelte component rendering is not covered. - The `yarn` justfile variable is added for platform-aware yarn invocation (Windows vs Unix). ## Before / after behavior Before: no `just test-ts`, no TypeScript coverage. After: `just test-ts` runs Vitest via ninja; `just test-ts --coverage` runs with V8 instrumentation. `just test --coverage` now spans all three stacks. --------- Co-authored-by: Abdo <abdo@abdnh.net>
24 lines
495 B
Bash
Executable File
24 lines
495 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
html="$1"
|
|
|
|
outdir="out/coverage/typescript"
|
|
YARN="out/extracted/node/bin/yarn"
|
|
|
|
mkdir -p "$outdir"
|
|
|
|
"$YARN" vitest:once \
|
|
--coverage.enabled true \
|
|
--coverage.provider=v8 \
|
|
--coverage.reporter=text-summary \
|
|
--coverage.reporter=json-summary \
|
|
${html:+--coverage.reporter=html} \
|
|
--coverage.reportsDirectory="../$outdir" \
|
|
--coverage.thresholds.lines=5
|
|
|
|
if [ "$html" = "--html" ]; then
|
|
echo "TypeScript coverage report: $outdir/index.html"
|
|
fi
|