@webpresso/agent-config 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/deploy/index.d.ts +1 -0
- package/dist/esm/deploy/index.js +3 -0
- package/dist/esm/dev/index.d.ts +1 -0
- package/dist/esm/dev/index.js +3 -0
- package/dist/esm/e2e/index.d.ts +1 -0
- package/dist/esm/e2e/index.js +3 -0
- package/dist/esm/process/index.d.ts +1 -0
- package/dist/esm/process/index.js +3 -0
- package/dist/esm/repo-root/index.d.ts +1 -0
- package/dist/esm/repo-root/index.js +3 -0
- package/dist/esm/stryker/index.js +47 -47
- package/dist/esm/tsconfig/base.json +3 -13
- package/dist/esm/vitest/bun-sqlite-shim.d.ts +1 -1
- package/dist/esm/vitest/bun-sqlite-shim.js +1 -1
- package/dist/esm/vitest/consumer-package.js +9 -9
- package/dist/esm/vitest/flakiness-reporter.d.ts +1 -1
- package/dist/esm/vitest/flakiness-reporter.js +5 -5
- package/dist/esm/vitest/node.d.ts +1 -1
- package/dist/esm/vitest/node.js +45 -45
- package/dist/esm/vitest/pool-defaults.js +5 -5
- package/dist/esm/vitest/react-router.d.ts +1 -1
- package/dist/esm/vitest/react-router.js +32 -32
- package/dist/esm/vitest/react-setup.js +0 -1
- package/dist/esm/vitest/react.d.ts +1 -1
- package/dist/esm/vitest/react.js +28 -28
- package/dist/esm/vitest/source-conditions.js +4 -4
- package/dist/esm/vitest/version-guard.js +9 -9
- package/dist/esm/vitest/workers.js +14 -14
- package/dist/esm/workers-test/durable-objects.d.ts +3 -3
- package/dist/esm/workers-test/durable-objects.js +5 -5
- package/dist/esm/workers-test/env.d.ts +1 -1
- package/dist/esm/workers-test/env.js +9 -9
- package/dist/esm/workers-test/execution-context.d.ts +2 -2
- package/dist/esm/workers-test/execution-context.js +1 -1
- package/dist/esm/workers-test/index.d.ts +8 -8
- package/dist/esm/workers-test/index.js +5 -5
- package/dist/esm/workers-test/requests.js +4 -4
- package/dist/esm/workers-test/setup.d.ts +5 -5
- package/dist/esm/workers-test/setup.js +8 -8
- package/package.json +66 -30
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webpresso/agent-core/deploy";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webpresso/agent-core/dev";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webpresso/agent-core/e2e";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webpresso/agent-core/process";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webpresso/agent-core/repo-root";
|
|
@@ -13,50 +13,50 @@
|
|
|
13
13
|
* }
|
|
14
14
|
*/
|
|
15
15
|
export const baseConfig = {
|
|
16
|
-
packageManager:
|
|
17
|
-
testRunner:
|
|
18
|
-
plugins: [
|
|
16
|
+
packageManager: "pnpm",
|
|
17
|
+
testRunner: "vitest",
|
|
18
|
+
plugins: ["@stryker-mutator/vitest-runner"],
|
|
19
19
|
ignorePatterns: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
"**/.git/**",
|
|
21
|
+
"**/node_modules/**",
|
|
22
|
+
"**/.stryker-tmp/**",
|
|
23
|
+
"**/.agent/**",
|
|
24
|
+
"**/.agents/**",
|
|
25
|
+
"**/.claude/**",
|
|
26
|
+
"**/.codex/**",
|
|
27
|
+
"**/.cursor/**",
|
|
28
|
+
"**/.opencode/**",
|
|
29
|
+
"**/.omx/**",
|
|
30
|
+
"**/dist/**",
|
|
31
|
+
"**/coverage/**",
|
|
32
|
+
"**/*.d.ts",
|
|
33
33
|
],
|
|
34
34
|
// Default mutate patterns - exclude all test files.
|
|
35
35
|
// Individual packages can override or extend these patterns.
|
|
36
36
|
mutate: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
"src/**/*.ts",
|
|
38
|
+
"src/**/*.tsx",
|
|
39
|
+
"apps/**/*.ts",
|
|
40
|
+
"apps/**/*.tsx",
|
|
41
|
+
"packages/**/*.ts",
|
|
42
|
+
"packages/**/*.tsx",
|
|
43
|
+
"infra/**/*.ts",
|
|
44
|
+
"infra/**/*.tsx",
|
|
45
|
+
"scripts/**/*.ts",
|
|
46
|
+
"scripts/**/*.tsx",
|
|
47
|
+
"!**/*.test.ts",
|
|
48
|
+
"!**/*.test.tsx",
|
|
49
|
+
"!**/*.spec.ts",
|
|
50
|
+
"!**/*.spec.tsx",
|
|
51
|
+
"!**/*.integration.test.ts",
|
|
52
|
+
"!**/*.integration.test.tsx",
|
|
53
|
+
"!**/*.workers.test.ts",
|
|
54
|
+
"!**/*.e2e.ts",
|
|
55
|
+
"!**/*.d.ts",
|
|
56
|
+
"!**/__fixtures__/**",
|
|
57
|
+
"!**/fixtures/**",
|
|
58
|
+
"!**/generated/**",
|
|
59
|
+
"!src/quality-sample.ts",
|
|
60
60
|
],
|
|
61
61
|
// Performance settings.
|
|
62
62
|
concurrency: 4,
|
|
@@ -78,20 +78,20 @@ export const baseConfig = {
|
|
|
78
78
|
// Exclude cosmetic mutations that don't affect behavior.
|
|
79
79
|
// This focuses mutation testing on actual business logic.
|
|
80
80
|
mutator: {
|
|
81
|
-
excludedMutations: [
|
|
81
|
+
excludedMutations: ["StringLiteral", "ArrayDeclaration"],
|
|
82
82
|
},
|
|
83
83
|
// Reporting.
|
|
84
|
-
reporters: [
|
|
84
|
+
reporters: ["html", "clear-text", "progress-append-only", "json"],
|
|
85
85
|
htmlReporter: {
|
|
86
|
-
fileName:
|
|
86
|
+
fileName: "reports/mutation/mutation-report.html",
|
|
87
87
|
},
|
|
88
88
|
jsonReporter: {
|
|
89
|
-
fileName:
|
|
89
|
+
fileName: "reports/mutation/mutation-report.json",
|
|
90
90
|
},
|
|
91
91
|
// Incremental mutation testing - caches results to avoid re-running unchanged code.
|
|
92
92
|
// Results stored in reports/stryker-incremental.json.
|
|
93
93
|
incremental: true,
|
|
94
|
-
incrementalFile:
|
|
94
|
+
incrementalFile: "reports/stryker-incremental.json",
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
97
|
* Extends baseConfig with TypeScript checker defaults.
|
|
@@ -106,8 +106,8 @@ export const baseConfig = {
|
|
|
106
106
|
*/
|
|
107
107
|
export const typescriptBaseConfig = {
|
|
108
108
|
...baseConfig,
|
|
109
|
-
checkers: [
|
|
110
|
-
tsconfigFile:
|
|
109
|
+
checkers: ["typescript"],
|
|
110
|
+
tsconfigFile: "tsconfig.json",
|
|
111
111
|
};
|
|
112
112
|
/**
|
|
113
113
|
* Extends typescriptBaseConfig for Cloudflare Workers packages whose vitest config
|
|
@@ -122,6 +122,6 @@ export const typescriptBaseConfig = {
|
|
|
122
122
|
*/
|
|
123
123
|
export const typescriptWorkersBaseConfig = {
|
|
124
124
|
...typescriptBaseConfig,
|
|
125
|
-
vitest: { configFile:
|
|
125
|
+
vitest: { configFile: "vitest.stryker.config.ts" },
|
|
126
126
|
};
|
|
127
127
|
export default baseConfig;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
"display": "Base",
|
|
4
4
|
"compilerOptions": {
|
|
5
5
|
"target": "ES2024",
|
|
6
|
-
"lib": [
|
|
7
|
-
"ES2024"
|
|
8
|
-
],
|
|
6
|
+
"lib": ["ES2024"],
|
|
9
7
|
"module": "ESNext",
|
|
10
8
|
"moduleResolution": "Bundler",
|
|
11
9
|
"resolveJsonModule": true,
|
|
@@ -23,15 +21,7 @@
|
|
|
23
21
|
"allowSyntheticDefaultImports": true,
|
|
24
22
|
"isolatedModules": true,
|
|
25
23
|
"verbatimModuleSyntax": true,
|
|
26
|
-
"types": [
|
|
27
|
-
"node"
|
|
28
|
-
]
|
|
24
|
+
"types": ["node"]
|
|
29
25
|
},
|
|
30
|
-
"exclude": [
|
|
31
|
-
"node_modules",
|
|
32
|
-
"dist",
|
|
33
|
-
"build",
|
|
34
|
-
".next",
|
|
35
|
-
".react-router"
|
|
36
|
-
]
|
|
26
|
+
"exclude": ["node_modules", "dist", "build", ".next", ".react-router"]
|
|
37
27
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from
|
|
2
|
-
import { createRequire } from
|
|
3
|
-
import { dirname, join, resolve } from
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
const localRequire = createRequire(import.meta.url);
|
|
5
5
|
function findNearestPackageRoot(startDirectory) {
|
|
6
6
|
let directory = resolve(startDirectory);
|
|
7
7
|
while (true) {
|
|
8
|
-
if (existsSync(join(directory,
|
|
8
|
+
if (existsSync(join(directory, "package.json"))) {
|
|
9
9
|
return directory;
|
|
10
10
|
}
|
|
11
11
|
const parent = dirname(directory);
|
|
@@ -20,10 +20,10 @@ function resolvePackageRootFromConfigArg(argv) {
|
|
|
20
20
|
const arg = argv[index];
|
|
21
21
|
if (!arg)
|
|
22
22
|
continue;
|
|
23
|
-
const configPath = arg ===
|
|
23
|
+
const configPath = arg === "--config" || arg === "-c"
|
|
24
24
|
? argv[index + 1]
|
|
25
|
-
: arg.startsWith(
|
|
26
|
-
? arg.slice(
|
|
25
|
+
: arg.startsWith("--config=")
|
|
26
|
+
? arg.slice("--config=".length)
|
|
27
27
|
: undefined;
|
|
28
28
|
if (!configPath)
|
|
29
29
|
continue;
|
|
@@ -45,7 +45,7 @@ function resolveConsumerPackageRoot() {
|
|
|
45
45
|
}
|
|
46
46
|
export const consumerPackageRoot = resolveConsumerPackageRoot();
|
|
47
47
|
const consumerPackageJsonPath = consumerPackageRoot
|
|
48
|
-
? join(consumerPackageRoot,
|
|
48
|
+
? join(consumerPackageRoot, "package.json")
|
|
49
49
|
: undefined;
|
|
50
50
|
export const requireFromConsumer = consumerPackageJsonPath
|
|
51
51
|
? createRequire(consumerPackageJsonPath)
|
|
@@ -54,7 +54,7 @@ export function readConsumerPackageJson() {
|
|
|
54
54
|
if (!consumerPackageJsonPath)
|
|
55
55
|
return undefined;
|
|
56
56
|
try {
|
|
57
|
-
return JSON.parse(readFileSync(consumerPackageJsonPath,
|
|
57
|
+
return JSON.parse(readFileSync(consumerPackageJsonPath, "utf8"));
|
|
58
58
|
}
|
|
59
59
|
catch {
|
|
60
60
|
return undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { mkdir, writeFile } from
|
|
2
|
-
import { resolve } from
|
|
3
|
-
const DEFAULT_REPORT_DIR = resolve(process.cwd(),
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
const DEFAULT_REPORT_DIR = resolve(process.cwd(), ".test-reports");
|
|
4
4
|
async function writeReport(path, payload) {
|
|
5
|
-
await mkdir(resolve(path,
|
|
5
|
+
await mkdir(resolve(path, ".."), { recursive: true });
|
|
6
6
|
await writeFile(path, JSON.stringify(payload, null, 2));
|
|
7
7
|
}
|
|
8
8
|
export function createFlakinessReporter(options = {}) {
|
|
@@ -18,7 +18,7 @@ export function createFlakinessReporter(options = {}) {
|
|
|
18
18
|
const meta = testCase.meta();
|
|
19
19
|
const moduleFilepath = testCase.module.filepath;
|
|
20
20
|
const result = testCase.result();
|
|
21
|
-
const duration = typeof result ===
|
|
21
|
+
const duration = typeof result === "object" && result !== null && "duration" in result
|
|
22
22
|
? (result.duration ?? null)
|
|
23
23
|
: null;
|
|
24
24
|
entries.push({
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* }))
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
import type { UserWorkspaceConfig, ViteUserConfigExport } from
|
|
14
|
+
import type { UserWorkspaceConfig, ViteUserConfigExport } from "vite-plus/test/config";
|
|
15
15
|
export type ResolveAliasEntry = {
|
|
16
16
|
find: string | RegExp;
|
|
17
17
|
replacement: string;
|
package/dist/esm/vitest/node.js
CHANGED
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
* }))
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
import { dirname, join } from
|
|
15
|
-
import { fileURLToPath } from
|
|
16
|
-
import { defineConfig } from
|
|
17
|
-
import { createFlakinessReporter } from
|
|
18
|
-
import { generatedRuntimeAliases } from
|
|
19
|
-
import { resolvedExecArgv, resolvedMaxWorkers, resolvedPool } from
|
|
20
|
-
import { assertNonWorkersVitest4 } from
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { defineConfig } from "vite-plus/test/config";
|
|
17
|
+
import { createFlakinessReporter } from "./flakiness-reporter.js";
|
|
18
|
+
import { generatedRuntimeAliases } from "./generated-runtime-aliases.js";
|
|
19
|
+
import { resolvedExecArgv, resolvedMaxWorkers, resolvedPool } from "./pool-defaults.js";
|
|
20
|
+
import { assertNonWorkersVitest4 } from "./version-guard.js";
|
|
21
21
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
22
|
const configDir = __dirname;
|
|
23
|
-
assertNonWorkersVitest4({ caller:
|
|
23
|
+
assertNonWorkersVitest4({ caller: "nodeConfig" });
|
|
24
24
|
// Route bun:sqlite → better-sqlite3 shim so Node-based vitest can load `@webpresso/agent-kit/blueprint`.
|
|
25
25
|
const bunSqliteAlias = [
|
|
26
26
|
{
|
|
27
27
|
find: /^bun:sqlite$/,
|
|
28
|
-
replacement: join(configDir,
|
|
28
|
+
replacement: join(configDir, "bun-sqlite-shim.js"),
|
|
29
29
|
},
|
|
30
30
|
];
|
|
31
31
|
// Force @webpresso/* packages through Vite's transform so the bun:sqlite alias applies even when imported from node_modules.
|
|
@@ -50,12 +50,12 @@ const webpressoInline = {
|
|
|
50
50
|
*/
|
|
51
51
|
export function createNodeProjects(name, options = {}) {
|
|
52
52
|
const unitInclude = options.unitInclude ?? [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
"src/**/*.test.ts",
|
|
54
|
+
"src/**/__tests__/**/*.test.{ts,tsx}",
|
|
55
|
+
"src/**/__tests__/**/*.spec.{ts,tsx}",
|
|
56
56
|
];
|
|
57
57
|
const extraUnitExclude = options.unitExclude ?? [];
|
|
58
|
-
const integrationInclude = options.integrationInclude ?? [
|
|
58
|
+
const integrationInclude = options.integrationInclude ?? ["src/**/*.integration.test.ts"];
|
|
59
59
|
const projectMaxWorkers = options.maxWorkers ?? resolvedMaxWorkers;
|
|
60
60
|
const projectFileParallelism = options.fileParallelism;
|
|
61
61
|
const projectIsolate = options.isolate;
|
|
@@ -78,7 +78,7 @@ export function createNodeProjects(name, options = {}) {
|
|
|
78
78
|
name: `${name}/unit`,
|
|
79
79
|
globals: true,
|
|
80
80
|
restoreMocks: true,
|
|
81
|
-
environment:
|
|
81
|
+
environment: "node",
|
|
82
82
|
pool: resolvedPool,
|
|
83
83
|
maxWorkers: projectMaxWorkers,
|
|
84
84
|
fileParallelism: projectFileParallelism,
|
|
@@ -87,9 +87,9 @@ export function createNodeProjects(name, options = {}) {
|
|
|
87
87
|
...(extraSetupFiles.length > 0 && { setupFiles: [...extraSetupFiles] }),
|
|
88
88
|
include: unitInclude,
|
|
89
89
|
exclude: [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
"**/*.integration.test.ts",
|
|
91
|
+
"**/.stryker-tmp/**",
|
|
92
|
+
"node_modules/**",
|
|
93
93
|
...extraUnitExclude,
|
|
94
94
|
],
|
|
95
95
|
},
|
|
@@ -101,7 +101,7 @@ export function createNodeProjects(name, options = {}) {
|
|
|
101
101
|
name: `${name}/integration`,
|
|
102
102
|
globals: true,
|
|
103
103
|
restoreMocks: true,
|
|
104
|
-
environment:
|
|
104
|
+
environment: "node",
|
|
105
105
|
pool: resolvedPool,
|
|
106
106
|
maxWorkers: projectMaxWorkers,
|
|
107
107
|
fileParallelism: projectFileParallelism,
|
|
@@ -109,11 +109,11 @@ export function createNodeProjects(name, options = {}) {
|
|
|
109
109
|
...(projectTestTimeout !== undefined && { testTimeout: projectTestTimeout }),
|
|
110
110
|
execArgv: resolvedExecArgv,
|
|
111
111
|
onConsoleLog: () => false,
|
|
112
|
-
silent: process.env.VITEST_CONSOLE ===
|
|
113
|
-
setupFiles: [join(configDir,
|
|
112
|
+
silent: process.env.VITEST_CONSOLE === "1" ? false : "passed-only",
|
|
113
|
+
setupFiles: [join(configDir, "node-setup.js"), ...extraSetupFiles],
|
|
114
114
|
include: integrationInclude,
|
|
115
|
-
exclude: [
|
|
116
|
-
reporters: [
|
|
115
|
+
exclude: ["**/.stryker-tmp/**", "node_modules/**"],
|
|
116
|
+
reporters: ["default", createFlakinessReporter()],
|
|
117
117
|
retry: process.env.CI ? 2 : 0,
|
|
118
118
|
},
|
|
119
119
|
},
|
|
@@ -128,14 +128,14 @@ export const nodeConfig = defineConfig({
|
|
|
128
128
|
test: {
|
|
129
129
|
globals: true,
|
|
130
130
|
restoreMocks: true,
|
|
131
|
-
environment:
|
|
132
|
-
setupFiles: [join(configDir,
|
|
131
|
+
environment: "node",
|
|
132
|
+
setupFiles: [join(configDir, "node-setup.js")],
|
|
133
133
|
onConsoleLog: () => false, // Suppress all console output
|
|
134
134
|
pool: resolvedPool,
|
|
135
135
|
// Suppress console output in tests by default.
|
|
136
136
|
// Tests should assert behavior, not log to stdout.
|
|
137
137
|
// To see console output, run with VITEST_CONSOLE=1.
|
|
138
|
-
silent: process.env.VITEST_CONSOLE ===
|
|
138
|
+
silent: process.env.VITEST_CONSOLE === "1" ? false : "passed-only",
|
|
139
139
|
// Note: Vitest v4 removed poolOptions - maxWorkers are now top-level
|
|
140
140
|
maxWorkers: resolvedMaxWorkers,
|
|
141
141
|
// Cap each fork worker's V8 heap to 2GB (Node 24 default is 4.2GB).
|
|
@@ -145,30 +145,30 @@ export const nodeConfig = defineConfig({
|
|
|
145
145
|
execArgv: resolvedExecArgv,
|
|
146
146
|
teardownTimeout: 10000,
|
|
147
147
|
include: [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
"src/**/*.test.ts",
|
|
149
|
+
"src/**/__tests__/**/*.test.{ts,tsx}",
|
|
150
|
+
"src/**/__tests__/**/*.spec.{ts,tsx}",
|
|
151
151
|
],
|
|
152
|
-
exclude: [
|
|
153
|
-
reporters: [
|
|
152
|
+
exclude: ["**/.stryker-tmp/**", "node_modules/**"],
|
|
153
|
+
reporters: ["default", createFlakinessReporter()],
|
|
154
154
|
retry: process.env.CI ? 2 : 0,
|
|
155
155
|
coverage: {
|
|
156
|
-
provider:
|
|
157
|
-
reporter: [
|
|
158
|
-
include: [
|
|
156
|
+
provider: "istanbul",
|
|
157
|
+
reporter: ["text", "json", "html", "lcov"],
|
|
158
|
+
include: ["src/**/*.ts"],
|
|
159
159
|
exclude: [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
"node_modules/",
|
|
161
|
+
"dist/",
|
|
162
|
+
"**/*.d.ts",
|
|
163
|
+
"**/*.config.*",
|
|
164
|
+
"**/tests/**",
|
|
165
|
+
"**/__tests__/**",
|
|
166
|
+
"**/__test-utils__/**",
|
|
167
|
+
"**/*.test.ts",
|
|
168
|
+
"**/*.spec.ts",
|
|
169
|
+
"**/index.ts", // Common exclusion for barrel exports
|
|
170
|
+
"**/types.ts",
|
|
171
|
+
"**/types/**",
|
|
172
172
|
],
|
|
173
173
|
// Industry-standard 80% coverage thresholds (Atlassian recommendation)
|
|
174
174
|
// 80% catches critical gaps without excessive build failures
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Centralizes shared-runner detection, env var overrides, Stryker compatibility,
|
|
5
5
|
* and execArgv logic used by node.ts, react.ts, and react-router.ts.
|
|
6
6
|
*/
|
|
7
|
-
import { cpus } from
|
|
7
|
+
import { cpus } from "node:os";
|
|
8
8
|
// Shared workspace runners need tighter worker caps to avoid oversubscription.
|
|
9
9
|
// `VP_RUN_CONCURRENCY_LIMIT` is the native Vite+ knob for shared task scheduling.
|
|
10
10
|
const underSharedWorkspaceRunner = !!process.env.VP_RUN_CONCURRENCY_LIMIT;
|
|
@@ -20,14 +20,14 @@ const parsePositiveInt = (value) => {
|
|
|
20
20
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
21
21
|
};
|
|
22
22
|
const requestedPool = process.env.VITEST_POOL;
|
|
23
|
-
const disableExecArgv = process.env.VITEST_DISABLE_EXEC_ARGV ===
|
|
23
|
+
const disableExecArgv = process.env.VITEST_DISABLE_EXEC_ARGV === "1";
|
|
24
24
|
const forcedMaxWorkers = parsePositiveInt(process.env.VITEST_MAX_WORKERS);
|
|
25
25
|
const forcedMinWorkers = parsePositiveInt(process.env.VITEST_MIN_WORKERS);
|
|
26
26
|
const isStryker = process.env.STRYKER_MUTATOR_WORKER !== undefined;
|
|
27
27
|
// Stryker's Vitest runner forces pool: 'threads' which rejects Node execArgv flags.
|
|
28
28
|
// Auto-clear execArgv to prevent ERR_WORKER_INVALID_EXEC_ARGV crashes.
|
|
29
29
|
// See: https://vitest.dev/config/pool.html#threads
|
|
30
|
-
export const resolvedPool = requestedPool ===
|
|
30
|
+
export const resolvedPool = requestedPool === "threads" ? "threads" : "forks";
|
|
31
31
|
export const resolvedMaxWorkers = forcedMaxWorkers ?? MAX_WORKERS;
|
|
32
32
|
export const resolvedMinWorkers = forcedMinWorkers ?? 1;
|
|
33
33
|
// --max-old-space-size=1536: Cap V8 heap to 1.5GB (Node 24 default is 4.2GB).
|
|
@@ -37,6 +37,6 @@ export const resolvedMinWorkers = forcedMinWorkers ?? 1;
|
|
|
37
37
|
// "Warning: `--localstorage-file` was provided without a valid path" in fork workers.
|
|
38
38
|
// Tests mock localStorage themselves; the built-in implementation is not needed.
|
|
39
39
|
// See: https://github.com/nodejs/node/issues/60303
|
|
40
|
-
export const resolvedExecArgv = disableExecArgv || resolvedPool ===
|
|
40
|
+
export const resolvedExecArgv = disableExecArgv || resolvedPool === "threads" || isStryker
|
|
41
41
|
? []
|
|
42
|
-
: [
|
|
42
|
+
: ["--max-old-space-size=1536", "--no-experimental-webstorage"];
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* }))
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import type { ViteUserConfigExport } from
|
|
19
|
+
import type { ViteUserConfigExport } from "vite-plus/test/config";
|
|
20
20
|
export declare const reactRouterConfig: ViteUserConfigExport;
|
|
21
21
|
export default reactRouterConfig;
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
* }))
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import react from
|
|
20
|
-
import { defineConfig } from
|
|
21
|
-
import { createFlakinessReporter } from
|
|
22
|
-
import { generatedRuntimeAliases, generatedRuntimeDedupe } from
|
|
23
|
-
import { resolvedExecArgv, resolvedMaxWorkers, resolvedMinWorkers, resolvedPool, } from
|
|
24
|
-
import { assertNonWorkersVitest4 } from
|
|
25
|
-
assertNonWorkersVitest4({ caller:
|
|
19
|
+
import react from "@vitejs/plugin-react";
|
|
20
|
+
import { defineConfig } from "vite-plus/test/config";
|
|
21
|
+
import { createFlakinessReporter } from "./flakiness-reporter.js";
|
|
22
|
+
import { generatedRuntimeAliases, generatedRuntimeDedupe } from "./generated-runtime-aliases.js";
|
|
23
|
+
import { resolvedExecArgv, resolvedMaxWorkers, resolvedMinWorkers, resolvedPool, } from "./pool-defaults.js";
|
|
24
|
+
import { assertNonWorkersVitest4 } from "./version-guard.js";
|
|
25
|
+
assertNonWorkersVitest4({ caller: "reactRouterConfig" });
|
|
26
26
|
export const reactRouterConfig = defineConfig({
|
|
27
27
|
plugins: [react()],
|
|
28
28
|
resolve: {
|
|
@@ -33,39 +33,39 @@ export const reactRouterConfig = defineConfig({
|
|
|
33
33
|
test: {
|
|
34
34
|
globals: true,
|
|
35
35
|
// happy-dom is ~40% faster than jsdom
|
|
36
|
-
environment:
|
|
36
|
+
environment: "happy-dom",
|
|
37
37
|
pool: resolvedPool,
|
|
38
38
|
maxWorkers: resolvedMaxWorkers,
|
|
39
39
|
minWorkers: resolvedMinWorkers,
|
|
40
40
|
execArgv: resolvedExecArgv,
|
|
41
41
|
// React Router apps use app/ directory
|
|
42
|
-
include: [
|
|
43
|
-
exclude: [
|
|
44
|
-
reporters: [
|
|
42
|
+
include: ["app/**/*.test.{ts,tsx}"],
|
|
43
|
+
exclude: ["**/.stryker-tmp/**", "node_modules/**"],
|
|
44
|
+
reporters: ["default", createFlakinessReporter()],
|
|
45
45
|
retry: process.env.CI ? 2 : 0,
|
|
46
46
|
coverage: {
|
|
47
|
-
provider:
|
|
48
|
-
reporter: [
|
|
49
|
-
include: [
|
|
47
|
+
provider: "v8",
|
|
48
|
+
reporter: ["text", "json", "html", "lcov"],
|
|
49
|
+
include: ["app/**/*.{ts,tsx}"],
|
|
50
50
|
exclude: [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
"node_modules/",
|
|
52
|
+
"test/",
|
|
53
|
+
"**/*.d.ts",
|
|
54
|
+
"**/*.config.*",
|
|
55
|
+
"**/mockData",
|
|
56
|
+
"build/",
|
|
57
|
+
"dist/",
|
|
58
|
+
".react-router/",
|
|
59
|
+
"**/*.test.{ts,tsx}",
|
|
60
|
+
"**/*.spec.{ts,tsx}",
|
|
61
|
+
"**/index.{ts,tsx}",
|
|
62
|
+
"**/types.ts",
|
|
63
|
+
"**/types.tsx",
|
|
64
|
+
"**/types/**",
|
|
65
65
|
// React Router specific
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
"app/routes.ts",
|
|
67
|
+
"app/entry.*.tsx",
|
|
68
|
+
"app/root.tsx",
|
|
69
69
|
],
|
|
70
70
|
thresholds: {
|
|
71
71
|
lines: 95,
|
|
@@ -76,7 +76,7 @@ export const reactRouterConfig = defineConfig({
|
|
|
76
76
|
},
|
|
77
77
|
},
|
|
78
78
|
optimizeDeps: {
|
|
79
|
-
include: [
|
|
79
|
+
include: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
82
|
export default reactRouterConfig;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*/
|
|
12
12
|
// Set IS_REACT_ACT_ENVIRONMENT to true for test environment
|
|
13
13
|
// This tells React 18+ that we're in a test environment and act() warnings should work correctly
|
|
14
|
-
;
|
|
15
14
|
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
16
15
|
/**
|
|
17
16
|
* Suppress console output globally for clean test output
|