@webpresso/agent-config 0.3.4 → 0.4.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/README.md +4 -0
- package/dist/esm/automation-authoring/index.d.ts +1 -0
- package/dist/esm/automation-authoring/index.js +3 -0
- package/dist/esm/stryker/index.d.ts +9 -9
- package/dist/esm/stryker/index.js +1 -1
- package/dist/esm/vitest/group-order.d.ts +2 -0
- package/dist/esm/vitest/group-order.js +17 -0
- package/dist/esm/vitest/node-source.d.ts +75 -0
- package/dist/esm/vitest/node-source.js +96 -0
- package/dist/esm/vitest/node.d.ts +4 -0
- package/dist/esm/vitest/node.js +65 -6
- package/dist/esm/vitest/pool-defaults.d.ts +1 -0
- package/dist/esm/vitest/pool-defaults.js +4 -4
- package/dist/esm/vitest/react.js +5 -0
- package/dist/esm/vitest/workers.d.ts +3 -0
- package/dist/esm/vitest/workers.js +5 -0
- package/package.json +26 -5
package/README.md
CHANGED
|
@@ -30,6 +30,10 @@ also re-exports the shared low-level primitives sourced from
|
|
|
30
30
|
- `@webpresso/agent-config/stryker`
|
|
31
31
|
- `@webpresso/agent-config/workers-test`
|
|
32
32
|
|
|
33
|
+
The Vitest surface includes stable group ordering, explicit staged-worker
|
|
34
|
+
selection, and root-aware Node project construction. Consumers keep ownership
|
|
35
|
+
of package-specific worker defaults, include patterns, aliases, and setup files.
|
|
36
|
+
|
|
33
37
|
## Relationship to other packages
|
|
34
38
|
|
|
35
39
|
- `@webpresso/agent-config` — consumer-installed package surface
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@webpresso/agent-core/automation-authoring";
|
|
@@ -55,11 +55,8 @@ export declare const baseConfig: {
|
|
|
55
55
|
* export default { ...typescriptBaseConfig, vitest: { configFile: 'vitest.stryker.config.ts' } }
|
|
56
56
|
*/
|
|
57
57
|
export declare const typescriptBaseConfig: {
|
|
58
|
-
checkers: string[];
|
|
59
|
-
tsconfigFile: string;
|
|
60
58
|
packageManager: string;
|
|
61
59
|
testRunner: string;
|
|
62
|
-
plugins: string[];
|
|
63
60
|
ignorePatterns: string[];
|
|
64
61
|
mutate: string[];
|
|
65
62
|
concurrency: number;
|
|
@@ -86,6 +83,9 @@ export declare const typescriptBaseConfig: {
|
|
|
86
83
|
};
|
|
87
84
|
incremental: boolean;
|
|
88
85
|
incrementalFile: string;
|
|
86
|
+
plugins: string[];
|
|
87
|
+
checkers: string[];
|
|
88
|
+
tsconfigFile: string;
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* Extends typescriptBaseConfig for Cloudflare Workers packages whose vitest config
|
|
@@ -99,14 +99,8 @@ export declare const typescriptBaseConfig: {
|
|
|
99
99
|
* export default { ...typescriptWorkersBaseConfig }
|
|
100
100
|
*/
|
|
101
101
|
export declare const typescriptWorkersBaseConfig: {
|
|
102
|
-
vitest: {
|
|
103
|
-
configFile: string;
|
|
104
|
-
};
|
|
105
|
-
checkers: string[];
|
|
106
|
-
tsconfigFile: string;
|
|
107
102
|
packageManager: string;
|
|
108
103
|
testRunner: string;
|
|
109
|
-
plugins: string[];
|
|
110
104
|
ignorePatterns: string[];
|
|
111
105
|
mutate: string[];
|
|
112
106
|
concurrency: number;
|
|
@@ -130,5 +124,11 @@ export declare const typescriptWorkersBaseConfig: {
|
|
|
130
124
|
};
|
|
131
125
|
incremental: boolean;
|
|
132
126
|
incrementalFile: string;
|
|
127
|
+
plugins: string[];
|
|
128
|
+
checkers: string[];
|
|
129
|
+
tsconfigFile: string;
|
|
130
|
+
vitest: {
|
|
131
|
+
configFile: string;
|
|
132
|
+
};
|
|
133
133
|
};
|
|
134
134
|
export default baseConfig;
|
|
@@ -26,7 +26,6 @@ export const baseConfig = {
|
|
|
26
26
|
"**/.codex/**",
|
|
27
27
|
"**/.cursor/**",
|
|
28
28
|
"**/.opencode/**",
|
|
29
|
-
"**/.omx/**",
|
|
30
29
|
"**/dist/**",
|
|
31
30
|
"**/coverage/**",
|
|
32
31
|
"**/*.d.ts",
|
|
@@ -106,6 +105,7 @@ export const baseConfig = {
|
|
|
106
105
|
*/
|
|
107
106
|
export const typescriptBaseConfig = {
|
|
108
107
|
...baseConfig,
|
|
108
|
+
plugins: [...baseConfig.plugins, "@stryker-mutator/typescript-checker"],
|
|
109
109
|
checkers: ["typescript"],
|
|
110
110
|
tsconfigFile: "tsconfig.json",
|
|
111
111
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readConsumerPackageJson } from "./consumer-package.js";
|
|
2
|
+
function stableHash(input) {
|
|
3
|
+
let hash = 0;
|
|
4
|
+
for (const char of input) {
|
|
5
|
+
hash = (hash * 31 + char.charCodeAt(0)) % 1000;
|
|
6
|
+
}
|
|
7
|
+
return hash;
|
|
8
|
+
}
|
|
9
|
+
function consumerName() {
|
|
10
|
+
return readConsumerPackageJson()?.name ?? process.cwd();
|
|
11
|
+
}
|
|
12
|
+
export function resolveVitestGroupOrderFor(seed, offset = 0) {
|
|
13
|
+
return 1000 + stableHash(seed) + offset;
|
|
14
|
+
}
|
|
15
|
+
export function resolveVitestGroupOrder(offset = 0) {
|
|
16
|
+
return resolveVitestGroupOrderFor(consumerName(), offset);
|
|
17
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed Vitest configuration: `nodeConfig` + the `@webpresso/source`
|
|
3
|
+
* resolve-condition contract.
|
|
4
|
+
*
|
|
5
|
+
* Consumers previously hand-rolled this composition themselves — a
|
|
6
|
+
* `mergeConfig(nodeConfig, createWebpressoSourceResolveConfig())` call plus a
|
|
7
|
+
* manual `resolve`/`ssr` spread, copy-pasted across every package that needs
|
|
8
|
+
* to run tests against source instead of `dist/`. This module is the single
|
|
9
|
+
* canonical, tested implementation those copies converge on.
|
|
10
|
+
*
|
|
11
|
+
* Usage in vitest.config.ts (single-config shape):
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createNodeSourceVitestConfig } from '@webpresso/agent-config/vitest/node-source'
|
|
14
|
+
*
|
|
15
|
+
* export default createNodeSourceVitestConfig({ extraConditions: ['source'] })
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Usage (unit/integration projects shape):
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createNodeSourceProjects } from '@webpresso/agent-config/vitest/node-source'
|
|
21
|
+
* import { nodeConfig } from '@webpresso/agent-config/vitest/node'
|
|
22
|
+
* import { mergeConfig } from 'vite-plus/test/config'
|
|
23
|
+
*
|
|
24
|
+
* export default mergeConfig(nodeConfig, {
|
|
25
|
+
* test: { projects: createNodeSourceProjects('my-package', { extraConditions: ['source'] }) },
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import type { UserWorkspaceConfig, ViteUserConfigExport } from "vite-plus/test/config";
|
|
30
|
+
import type { CreateNodeProjectsOptions, ResolveAliasEntry } from "./node.js";
|
|
31
|
+
export interface CreateNodeSourceVitestConfigOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Extra resolve conditions appended AFTER the full base
|
|
34
|
+
* `@webpresso/source` condition set — applied identically to both
|
|
35
|
+
* top-level `resolve.conditions` and `ssr.resolve.conditions`. Framework
|
|
36
|
+
* packages pass `['source']`.
|
|
37
|
+
*/
|
|
38
|
+
extraConditions?: readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Extra resolve aliases appended after `nodeConfig`'s built-in alias array
|
|
41
|
+
* (generated runtime aliases + the bun:sqlite shim).
|
|
42
|
+
*/
|
|
43
|
+
alias?: readonly ResolveAliasEntry[];
|
|
44
|
+
tsconfigPaths?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Shallow-merged into the base `test` block (`{ ...nodeConfig.test,
|
|
47
|
+
* ...test }`) — NOT deep-merged. A deep merge (e.g. via `mergeConfig`)
|
|
48
|
+
* would concatenate array fields such as `setupFiles`/`execArgv`/coverage
|
|
49
|
+
* `include`/`exclude` with `nodeConfig`'s own copies of those same arrays,
|
|
50
|
+
* which previously crashed forks-pool worker startup when a consumer
|
|
51
|
+
* config spread `nodeConfig.test` and then merged the result again.
|
|
52
|
+
* Provide a full replacement value for any array field you want to change.
|
|
53
|
+
*/
|
|
54
|
+
test?: UserWorkspaceConfig["test"];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Compose `nodeConfig` with the `@webpresso/source` resolve-condition
|
|
58
|
+
* contract into a single flat Vitest config.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createNodeSourceVitestConfig(options?: CreateNodeSourceVitestConfigOptions): ViteUserConfigExport;
|
|
61
|
+
export interface CreateNodeSourceProjectsOptions extends CreateNodeProjectsOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Extra resolve conditions appended AFTER the full base
|
|
64
|
+
* `@webpresso/source` condition set on BOTH the unit and integration
|
|
65
|
+
* projects (top-level `resolve.conditions` and `ssr.resolve.conditions`).
|
|
66
|
+
*/
|
|
67
|
+
extraConditions?: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create unit/integration Vitest projects (via `createNodeProjects`) with the
|
|
71
|
+
* `@webpresso/source` resolve-condition contract layered onto each project,
|
|
72
|
+
* without disturbing `createNodeProjects`'s own `extraAlias` /
|
|
73
|
+
* `extraInline` / `extraSetupFiles` seam.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createNodeSourceProjects(name: string, options?: CreateNodeSourceProjectsOptions): UserWorkspaceConfig[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed Vitest configuration: `nodeConfig` + the `@webpresso/source`
|
|
3
|
+
* resolve-condition contract.
|
|
4
|
+
*
|
|
5
|
+
* Consumers previously hand-rolled this composition themselves — a
|
|
6
|
+
* `mergeConfig(nodeConfig, createWebpressoSourceResolveConfig())` call plus a
|
|
7
|
+
* manual `resolve`/`ssr` spread, copy-pasted across every package that needs
|
|
8
|
+
* to run tests against source instead of `dist/`. This module is the single
|
|
9
|
+
* canonical, tested implementation those copies converge on.
|
|
10
|
+
*
|
|
11
|
+
* Usage in vitest.config.ts (single-config shape):
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createNodeSourceVitestConfig } from '@webpresso/agent-config/vitest/node-source'
|
|
14
|
+
*
|
|
15
|
+
* export default createNodeSourceVitestConfig({ extraConditions: ['source'] })
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Usage (unit/integration projects shape):
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createNodeSourceProjects } from '@webpresso/agent-config/vitest/node-source'
|
|
21
|
+
* import { nodeConfig } from '@webpresso/agent-config/vitest/node'
|
|
22
|
+
* import { mergeConfig } from 'vite-plus/test/config'
|
|
23
|
+
*
|
|
24
|
+
* export default mergeConfig(nodeConfig, {
|
|
25
|
+
* test: { projects: createNodeSourceProjects('my-package', { extraConditions: ['source'] }) },
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { createNodeProjects, nodeConfig } from "./node.js";
|
|
30
|
+
import { createWebpressoSourceResolveConfig } from "./source-conditions.js";
|
|
31
|
+
const baseConfig = nodeConfig;
|
|
32
|
+
const baseNodeAlias = Array.isArray(baseConfig.resolve?.alias)
|
|
33
|
+
? baseConfig.resolve.alias
|
|
34
|
+
: [];
|
|
35
|
+
function appendConditions(sourceResolve, extraConditions) {
|
|
36
|
+
return {
|
|
37
|
+
resolve: [...sourceResolve.resolve.conditions, ...extraConditions],
|
|
38
|
+
ssr: [...sourceResolve.ssr.resolve.conditions, ...extraConditions],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compose `nodeConfig` with the `@webpresso/source` resolve-condition
|
|
43
|
+
* contract into a single flat Vitest config.
|
|
44
|
+
*/
|
|
45
|
+
export function createNodeSourceVitestConfig(options = {}) {
|
|
46
|
+
const { extraConditions = [], alias = [], tsconfigPaths, test } = options;
|
|
47
|
+
const sourceResolve = createWebpressoSourceResolveConfig(tsconfigPaths === undefined ? {} : { tsconfigPaths });
|
|
48
|
+
const conditions = appendConditions(sourceResolve, extraConditions);
|
|
49
|
+
return {
|
|
50
|
+
...nodeConfig,
|
|
51
|
+
resolve: {
|
|
52
|
+
...baseConfig.resolve,
|
|
53
|
+
...sourceResolve.resolve,
|
|
54
|
+
alias: [...baseNodeAlias, ...alias],
|
|
55
|
+
conditions: conditions.resolve,
|
|
56
|
+
},
|
|
57
|
+
ssr: {
|
|
58
|
+
...baseConfig.ssr,
|
|
59
|
+
resolve: {
|
|
60
|
+
...baseConfig.ssr?.resolve,
|
|
61
|
+
conditions: conditions.ssr,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
test: {
|
|
65
|
+
...baseConfig.test,
|
|
66
|
+
...test,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create unit/integration Vitest projects (via `createNodeProjects`) with the
|
|
72
|
+
* `@webpresso/source` resolve-condition contract layered onto each project,
|
|
73
|
+
* without disturbing `createNodeProjects`'s own `extraAlias` /
|
|
74
|
+
* `extraInline` / `extraSetupFiles` seam.
|
|
75
|
+
*/
|
|
76
|
+
export function createNodeSourceProjects(name, options = {}) {
|
|
77
|
+
const { extraConditions = [], ...projectOptions } = options;
|
|
78
|
+
const conditions = appendConditions(createWebpressoSourceResolveConfig(), extraConditions);
|
|
79
|
+
return createNodeProjects(name, projectOptions).map((project) => {
|
|
80
|
+
const composableProject = project;
|
|
81
|
+
return {
|
|
82
|
+
...project,
|
|
83
|
+
resolve: {
|
|
84
|
+
...composableProject.resolve,
|
|
85
|
+
conditions: conditions.resolve,
|
|
86
|
+
},
|
|
87
|
+
ssr: {
|
|
88
|
+
...composableProject.ssr,
|
|
89
|
+
resolve: {
|
|
90
|
+
...composableProject.ssr?.resolve,
|
|
91
|
+
conditions: conditions.ssr,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -16,7 +16,10 @@ export type ResolveAliasEntry = {
|
|
|
16
16
|
find: string | RegExp;
|
|
17
17
|
replacement: string;
|
|
18
18
|
};
|
|
19
|
+
export declare function resolveStagedMaxWorkers(defaultMaxWorkers: number): number;
|
|
19
20
|
export interface CreateNodeProjectsOptions {
|
|
21
|
+
/** Absolute package root. A verified-empty root omits the integration project. */
|
|
22
|
+
root?: string;
|
|
20
23
|
unitInclude?: string[];
|
|
21
24
|
unitExclude?: string[];
|
|
22
25
|
integrationInclude?: string[];
|
|
@@ -24,6 +27,7 @@ export interface CreateNodeProjectsOptions {
|
|
|
24
27
|
fileParallelism?: boolean;
|
|
25
28
|
isolate?: boolean;
|
|
26
29
|
testTimeout?: number;
|
|
30
|
+
hookTimeout?: number;
|
|
27
31
|
/**
|
|
28
32
|
* Extra resolve aliases appended (after the built-ins) to BOTH the unit and
|
|
29
33
|
* integration projects. Lets a consumer inject repo-specific module rewrites
|
package/dist/esm/vitest/node.js
CHANGED
|
@@ -11,15 +11,19 @@
|
|
|
11
11
|
* }))
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { globSync, readdirSync, statSync } from "node:fs";
|
|
15
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
15
16
|
import { fileURLToPath } from "node:url";
|
|
16
17
|
import { defineConfig } from "vite-plus/test/config";
|
|
17
18
|
import { createFlakinessReporter } from "./flakiness-reporter.js";
|
|
18
19
|
import { generatedRuntimeAliases } from "./generated-runtime-aliases.js";
|
|
19
|
-
import {
|
|
20
|
+
import { resolveVitestGroupOrder } from "./group-order.js";
|
|
21
|
+
import { parsePositiveInt, resolvedExecArgv, resolvedMaxWorkers, resolvedPool, } from "./pool-defaults.js";
|
|
20
22
|
import { assertNonWorkersVitest4 } from "./version-guard.js";
|
|
21
23
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
24
|
const configDir = __dirname;
|
|
25
|
+
const groupOrder = resolveVitestGroupOrder();
|
|
26
|
+
const maxDiscoveryEntries = 10_000;
|
|
23
27
|
assertNonWorkersVitest4({ caller: "nodeConfig" });
|
|
24
28
|
// Route bun:sqlite → better-sqlite3 shim so Node-based vitest can load `@webpresso/agent-kit/blueprint`.
|
|
25
29
|
const bunSqliteAlias = [
|
|
@@ -32,6 +36,46 @@ const bunSqliteAlias = [
|
|
|
32
36
|
const webpressoInline = {
|
|
33
37
|
deps: { inline: [/webpresso/] },
|
|
34
38
|
};
|
|
39
|
+
export function resolveStagedMaxWorkers(defaultMaxWorkers) {
|
|
40
|
+
const forcedMaxWorkers = parsePositiveInt(process.env["VITEST_MAX_WORKERS"]);
|
|
41
|
+
if (forcedMaxWorkers !== undefined)
|
|
42
|
+
return forcedMaxWorkers;
|
|
43
|
+
return process.env["VP_RUN_CONCURRENCY_LIMIT"] ? 1 : defaultMaxWorkers;
|
|
44
|
+
}
|
|
45
|
+
function hasMatchingFiles(root, patterns) {
|
|
46
|
+
try {
|
|
47
|
+
if (!isAbsolute(root) || !statSync(root).isDirectory())
|
|
48
|
+
return true;
|
|
49
|
+
const matches = globSync(patterns, {
|
|
50
|
+
cwd: root,
|
|
51
|
+
exclude: ["**/.stryker-tmp/**", "**/node_modules/**"],
|
|
52
|
+
});
|
|
53
|
+
if (matches.length > 0)
|
|
54
|
+
return true;
|
|
55
|
+
// `globSync` can silently skip EACCES directories and report an empty
|
|
56
|
+
// result. Enumerate the same discoverable tree explicitly before treating
|
|
57
|
+
// emptiness as proof; Dirent checks avoid following symlink loops.
|
|
58
|
+
const pending = [root];
|
|
59
|
+
let discoveredEntries = 0;
|
|
60
|
+
while (pending.length > 0) {
|
|
61
|
+
const directory = pending.pop();
|
|
62
|
+
if (!directory)
|
|
63
|
+
continue;
|
|
64
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
65
|
+
discoveredEntries += 1;
|
|
66
|
+
if (discoveredEntries > maxDiscoveryEntries)
|
|
67
|
+
return true;
|
|
68
|
+
if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== ".stryker-tmp") {
|
|
69
|
+
pending.push(join(directory, entry.name));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
35
79
|
/**
|
|
36
80
|
* Create vitest projects for unit/integration test split.
|
|
37
81
|
*
|
|
@@ -60,6 +104,7 @@ export function createNodeProjects(name, options = {}) {
|
|
|
60
104
|
const projectFileParallelism = options.fileParallelism;
|
|
61
105
|
const projectIsolate = options.isolate;
|
|
62
106
|
const projectTestTimeout = options.testTimeout;
|
|
107
|
+
const projectHookTimeout = options.hookTimeout;
|
|
63
108
|
const extraAlias = options.extraAlias ?? [];
|
|
64
109
|
const extraSetupFiles = options.extraSetupFiles ?? [];
|
|
65
110
|
const sharedResolve = {
|
|
@@ -69,13 +114,16 @@ export function createNodeProjects(name, options = {}) {
|
|
|
69
114
|
const projectInline = {
|
|
70
115
|
deps: { inline: [...webpressoInline.deps.inline, ...(options.extraInline ?? [])] },
|
|
71
116
|
};
|
|
72
|
-
|
|
117
|
+
const projects = [
|
|
73
118
|
{
|
|
74
119
|
resolve: sharedResolve,
|
|
75
120
|
server: projectInline,
|
|
76
121
|
test: {
|
|
77
122
|
server: projectInline,
|
|
78
123
|
name: `${name}/unit`,
|
|
124
|
+
sequence: {
|
|
125
|
+
groupOrder,
|
|
126
|
+
},
|
|
79
127
|
globals: true,
|
|
80
128
|
restoreMocks: true,
|
|
81
129
|
environment: "node",
|
|
@@ -84,6 +132,7 @@ export function createNodeProjects(name, options = {}) {
|
|
|
84
132
|
fileParallelism: projectFileParallelism,
|
|
85
133
|
isolate: projectIsolate,
|
|
86
134
|
...(projectTestTimeout !== undefined && { testTimeout: projectTestTimeout }),
|
|
135
|
+
...(projectHookTimeout !== undefined && { hookTimeout: projectHookTimeout }),
|
|
87
136
|
...(extraSetupFiles.length > 0 && { setupFiles: [...extraSetupFiles] }),
|
|
88
137
|
include: unitInclude,
|
|
89
138
|
exclude: [
|
|
@@ -94,11 +143,16 @@ export function createNodeProjects(name, options = {}) {
|
|
|
94
143
|
],
|
|
95
144
|
},
|
|
96
145
|
},
|
|
97
|
-
|
|
146
|
+
];
|
|
147
|
+
if (!options.root || hasMatchingFiles(options.root, integrationInclude)) {
|
|
148
|
+
projects.push({
|
|
98
149
|
resolve: sharedResolve,
|
|
99
150
|
server: projectInline,
|
|
100
151
|
test: {
|
|
101
152
|
name: `${name}/integration`,
|
|
153
|
+
sequence: {
|
|
154
|
+
groupOrder: groupOrder + 1,
|
|
155
|
+
},
|
|
102
156
|
globals: true,
|
|
103
157
|
restoreMocks: true,
|
|
104
158
|
environment: "node",
|
|
@@ -107,6 +161,7 @@ export function createNodeProjects(name, options = {}) {
|
|
|
107
161
|
fileParallelism: projectFileParallelism,
|
|
108
162
|
isolate: projectIsolate,
|
|
109
163
|
...(projectTestTimeout !== undefined && { testTimeout: projectTestTimeout }),
|
|
164
|
+
...(projectHookTimeout !== undefined && { hookTimeout: projectHookTimeout }),
|
|
110
165
|
execArgv: resolvedExecArgv,
|
|
111
166
|
onConsoleLog: () => false,
|
|
112
167
|
silent: process.env.VITEST_CONSOLE === "1" ? false : "passed-only",
|
|
@@ -116,8 +171,9 @@ export function createNodeProjects(name, options = {}) {
|
|
|
116
171
|
reporters: ["default", createFlakinessReporter()],
|
|
117
172
|
retry: process.env.CI ? 2 : 0,
|
|
118
173
|
},
|
|
119
|
-
}
|
|
120
|
-
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return projects;
|
|
121
177
|
}
|
|
122
178
|
export const nodeConfig = defineConfig({
|
|
123
179
|
resolve: {
|
|
@@ -126,6 +182,9 @@ export const nodeConfig = defineConfig({
|
|
|
126
182
|
},
|
|
127
183
|
server: webpressoInline,
|
|
128
184
|
test: {
|
|
185
|
+
sequence: {
|
|
186
|
+
groupOrder,
|
|
187
|
+
},
|
|
129
188
|
globals: true,
|
|
130
189
|
restoreMocks: true,
|
|
131
190
|
environment: "node",
|
|
@@ -4,6 +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
|
+
export declare const parsePositiveInt: (value: string | undefined) => number | undefined;
|
|
7
8
|
export declare const resolvedPool: string;
|
|
8
9
|
export declare const resolvedMaxWorkers: number;
|
|
9
10
|
export declare const resolvedMinWorkers: number;
|
|
@@ -13,11 +13,11 @@ const underSharedWorkspaceRunner = !!process.env.VP_RUN_CONCURRENCY_LIMIT;
|
|
|
13
13
|
// inner fork workers causes frequent shutdown timeouts and EPIPE crashes on
|
|
14
14
|
// large happy-dom / integration suites.
|
|
15
15
|
const MAX_WORKERS = underSharedWorkspaceRunner ? 1 : Math.max(1, Math.floor(cpus().length * 0.75));
|
|
16
|
-
const parsePositiveInt = (value) => {
|
|
17
|
-
if (!value)
|
|
16
|
+
export const parsePositiveInt = (value) => {
|
|
17
|
+
if (!value || !/^\d+$/.test(value))
|
|
18
18
|
return;
|
|
19
|
-
const parsed = Number
|
|
20
|
-
return Number.
|
|
19
|
+
const parsed = Number(value);
|
|
20
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
21
21
|
};
|
|
22
22
|
const requestedPool = process.env.VITEST_POOL;
|
|
23
23
|
const disableExecArgv = process.env.VITEST_DISABLE_EXEC_ARGV === "1";
|
package/dist/esm/vitest/react.js
CHANGED
|
@@ -20,9 +20,11 @@ import react from "@vitejs/plugin-react";
|
|
|
20
20
|
import { defineConfig } from "vite-plus/test/config";
|
|
21
21
|
import { createFlakinessReporter } from "./flakiness-reporter.js";
|
|
22
22
|
import { generatedRuntimeAliases, generatedRuntimeDedupe } from "./generated-runtime-aliases.js";
|
|
23
|
+
import { resolveVitestGroupOrder } from "./group-order.js";
|
|
23
24
|
import { resolvedExecArgv, resolvedMaxWorkers, resolvedMinWorkers, resolvedPool, } from "./pool-defaults.js";
|
|
24
25
|
import { assertNonWorkersVitest4 } from "./version-guard.js";
|
|
25
26
|
assertNonWorkersVitest4({ caller: "reactConfig" });
|
|
27
|
+
const groupOrder = resolveVitestGroupOrder();
|
|
26
28
|
export const reactConfig = defineConfig({
|
|
27
29
|
plugins: [react()],
|
|
28
30
|
resolve: {
|
|
@@ -31,6 +33,9 @@ export const reactConfig = defineConfig({
|
|
|
31
33
|
tsconfigPaths: true,
|
|
32
34
|
},
|
|
33
35
|
test: {
|
|
36
|
+
sequence: {
|
|
37
|
+
groupOrder,
|
|
38
|
+
},
|
|
34
39
|
globals: true,
|
|
35
40
|
restoreAllMocks: true,
|
|
36
41
|
environment: "happy-dom",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defineConfig } from "vite-plus/test/config";
|
|
2
2
|
import { createFlakinessReporter } from "./flakiness-reporter.js";
|
|
3
|
+
import { resolveVitestGroupOrder } from "./group-order.js";
|
|
3
4
|
import { assertVitest4 } from "./version-guard.js";
|
|
4
5
|
assertVitest4({ caller: "workersConfig" });
|
|
6
|
+
const groupOrder = resolveVitestGroupOrder();
|
|
5
7
|
/**
|
|
6
8
|
* Shared Vitest configuration for Cloudflare Workers
|
|
7
9
|
*/
|
|
@@ -10,6 +12,9 @@ export const workersConfig = defineConfig({
|
|
|
10
12
|
tsconfigPaths: true,
|
|
11
13
|
},
|
|
12
14
|
test: {
|
|
15
|
+
sequence: {
|
|
16
|
+
groupOrder,
|
|
17
|
+
},
|
|
13
18
|
globals: true,
|
|
14
19
|
restoreMocks: true,
|
|
15
20
|
reporters: ["default", createFlakinessReporter()],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpresso/agent-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared vitest, tsconfig, stryker, and workers-test config for webpresso consumers. Binary-free — pure test/config tooling.",
|
|
6
6
|
"homepage": "https://github.com/webpresso/agent-kit#readme",
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"exports": {
|
|
25
|
+
"./automation-authoring": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/esm/automation-authoring/index.d.ts",
|
|
28
|
+
"default": "./dist/esm/automation-authoring/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
25
31
|
"./deploy": {
|
|
26
32
|
"import": {
|
|
27
33
|
"types": "./dist/esm/deploy/index.d.ts",
|
|
@@ -100,12 +106,24 @@
|
|
|
100
106
|
"default": "./dist/esm/vitest/flakiness-reporter.js"
|
|
101
107
|
}
|
|
102
108
|
},
|
|
109
|
+
"./vitest/group-order": {
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/esm/vitest/group-order.d.ts",
|
|
112
|
+
"default": "./dist/esm/vitest/group-order.js"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
103
115
|
"./vitest/node": {
|
|
104
116
|
"import": {
|
|
105
117
|
"types": "./dist/esm/vitest/node.d.ts",
|
|
106
118
|
"default": "./dist/esm/vitest/node.js"
|
|
107
119
|
}
|
|
108
120
|
},
|
|
121
|
+
"./vitest/node-source": {
|
|
122
|
+
"import": {
|
|
123
|
+
"types": "./dist/esm/vitest/node-source.d.ts",
|
|
124
|
+
"default": "./dist/esm/vitest/node-source.js"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
109
127
|
"./vitest/react": {
|
|
110
128
|
"import": {
|
|
111
129
|
"types": "./dist/esm/vitest/react.d.ts",
|
|
@@ -161,10 +179,10 @@
|
|
|
161
179
|
},
|
|
162
180
|
"dependencies": {
|
|
163
181
|
"@vitejs/plugin-react": "^6.0.3",
|
|
164
|
-
"@webpresso/agent-core": "0.1.
|
|
165
|
-
"vite": "^8.1.
|
|
166
|
-
"vite-plus": "^0.2.
|
|
167
|
-
"vitest": "^4.1.
|
|
182
|
+
"@webpresso/agent-core": "0.1.4",
|
|
183
|
+
"vite": "^8.1.5",
|
|
184
|
+
"vite-plus": "^0.2.4",
|
|
185
|
+
"vitest": "^4.1.10"
|
|
168
186
|
},
|
|
169
187
|
"peerDependencies": {
|
|
170
188
|
"@cloudflare/vitest-pool-workers": "*",
|
|
@@ -207,6 +225,7 @@
|
|
|
207
225
|
"src/**/__fixtures__/**"
|
|
208
226
|
],
|
|
209
227
|
"exports": {
|
|
228
|
+
"./automation-authoring": "./src/automation-authoring/index.ts",
|
|
210
229
|
"./deploy": "./src/deploy/index.ts",
|
|
211
230
|
"./dev": "./src/dev/index.ts",
|
|
212
231
|
"./e2e": "./src/e2e/index.ts",
|
|
@@ -220,7 +239,9 @@
|
|
|
220
239
|
"./tsconfig/react-library.json": "./src/tsconfig/react-library.json",
|
|
221
240
|
"./tsconfig/react-router.json": "./src/tsconfig/react-router.json",
|
|
222
241
|
"./vitest/flakiness-reporter": "./src/vitest/flakiness-reporter.ts",
|
|
242
|
+
"./vitest/group-order": "./src/vitest/group-order.ts",
|
|
223
243
|
"./vitest/node": "./src/vitest/node.ts",
|
|
244
|
+
"./vitest/node-source": "./src/vitest/node-source.ts",
|
|
224
245
|
"./vitest/react": "./src/vitest/react.ts",
|
|
225
246
|
"./vitest/react-router": "./src/vitest/react-router.ts",
|
|
226
247
|
"./vitest/react-setup": "./src/vitest/react-setup.ts",
|