test: fix unit coverage scope

This commit is contained in:
Peter Steinberger
2026-04-20 23:34:21 +01:00
parent a216b4ebc3
commit 04cdc33731
3 changed files with 15 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ title: "Tests"
- Full testing kit (suites, live, Docker): [Testing](/help/testing)
- `pnpm test:force`: Kills any lingering gateway process holding the default control port, then runs the full Vitest suite with an isolated gateway port so server tests dont collide with a running instance. Use this when a prior gateway run left port 18789 occupied.
- `pnpm test:coverage`: Runs the unit suite with V8 coverage (via `vitest.unit.config.ts`). Global thresholds are 70% lines/branches/functions/statements. Coverage excludes integration-heavy entrypoints (CLI wiring, gateway/telegram bridges, webchat static server) to keep the target focused on unit-testable logic.
- `pnpm test:coverage`: Runs the unit suite with V8 coverage (via `vitest.unit.config.ts`). This is a loaded-file unit coverage gate, not whole-repo all-file coverage. Thresholds are 70% lines/functions/statements and 55% branches. Because `coverage.all` is false, the gate measures files loaded by the unit coverage suite instead of treating every split-lane source file as uncovered.
- `pnpm test:coverage:changed`: Runs unit coverage only for files changed since `origin/main`.
- `pnpm test:changed`: expands changed git paths into scoped Vitest lanes when the diff only touches routable source/test files. Config/setup changes still fall back to the native root projects run so wiring edits rerun broadly when needed.
- `pnpm changed:lanes`: shows the architectural lanes triggered by the diff against `origin/main`.

View File

@@ -254,7 +254,6 @@ export const sharedVitestConfig = {
branches: 55,
statements: 70,
},
include: ["./src/**/*.ts"],
exclude: [
`${BUNDLED_PLUGIN_ROOT_DIR}/**`,
"apps/**",

View File

@@ -1,4 +1,4 @@
import { defineProject } from "vitest/config";
import { defineConfig } from "vitest/config";
import { loadPatternListFromEnv, narrowIncludePatternsForCli } from "./vitest.pattern-file.ts";
import { resolveVitestIsolation } from "./vitest.scoped-config.ts";
import {
@@ -50,7 +50,8 @@ export function createUnitVitestConfigWithOptions(
}
return ![...protectedIncludeFiles].some((file) => pattern === file || pattern.endsWith("/**"));
});
return defineProject({
const extraExcludePatterns = options.extraExcludePatterns ?? [];
return defineConfig({
...sharedVitestConfig,
test: {
...sharedTest,
@@ -70,10 +71,20 @@ export function createUnitVitestConfigWithOptions(
...exclude,
...baseExcludePatterns,
...unitFastTestFiles,
...(options.extraExcludePatterns ?? []),
...extraExcludePatterns,
...loadExtraExcludePatternsFromEnv(env),
]),
],
coverage: {
...sharedTest.coverage,
exclude: [
...new Set([
...(sharedTest.coverage?.exclude ?? []),
...baseExcludePatterns,
...extraExcludePatterns,
]),
],
},
...(cliIncludePatterns !== null ? { passWithNoTests: true } : {}),
},
});