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

@@ -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 } : {}),
},
});