@elench/testkit 0.1.81 → 0.1.82
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 +28 -21
- package/lib/config-api/auth-fixtures.mjs +762 -0
- package/lib/config-api/index.d.ts +92 -108
- package/lib/config-api/index.mjs +22 -12
- package/lib/config-api/index.test.mjs +61 -222
- package/lib/index.d.ts +29 -9
- package/lib/runtime/index.d.ts +50 -33
- package/lib/runtime/index.mjs +0 -1
- package/lib/runtime-src/k6/http-suite-runtime.js +147 -0
- package/lib/runtime-src/k6/http.js +80 -41
- package/lib/runtime-src/k6/scenario-suite.js +13 -110
- package/lib/runtime-src/k6/suite.js +13 -107
- package/node_modules/@elench/next-analysis/package.json +1 -1
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/package.json +5 -5
- package/lib/config-api/profiles.mjs +0 -640
|
@@ -7,17 +7,22 @@ import {
|
|
|
7
7
|
startFailureCollection,
|
|
8
8
|
} from "./checks.js";
|
|
9
9
|
import {
|
|
10
|
-
createHttpClient,
|
|
11
10
|
emitHttpTraceCollectionArtifact,
|
|
12
|
-
getEnv,
|
|
13
11
|
startHttpTraceCollection,
|
|
14
12
|
} from "./http.js";
|
|
15
13
|
import {
|
|
16
14
|
clearRuntimeContext,
|
|
17
15
|
registerRuntimeContext,
|
|
18
|
-
resolveHttpProfile,
|
|
19
16
|
} from "../../config-api/runtime.mjs";
|
|
20
17
|
import { createScenarioRuntime } from "./scenario-runtime.js";
|
|
18
|
+
import {
|
|
19
|
+
buildRuntimeExceptionDetail,
|
|
20
|
+
createSuiteActors,
|
|
21
|
+
formatFatalSuiteError,
|
|
22
|
+
mergeProfileConfig,
|
|
23
|
+
normalizeSuiteArgs,
|
|
24
|
+
resolveRuntimeConfig,
|
|
25
|
+
} from "./http-suite-runtime.js";
|
|
21
26
|
|
|
22
27
|
export function defineScenarioSuite(configOrRun, maybeRun) {
|
|
23
28
|
const { config, run } = normalizeSuiteArgs(configOrRun, maybeRun);
|
|
@@ -45,7 +50,8 @@ export function defineScenarioSuite(configOrRun, maybeRun) {
|
|
|
45
50
|
}
|
|
46
51
|
},
|
|
47
52
|
exec(setupData) {
|
|
48
|
-
const resolved = resolveRuntimeConfig(config);
|
|
53
|
+
const resolved = resolveRuntimeConfig(config, setupData);
|
|
54
|
+
const actorContext = createSuiteActors(setupData, resolved.client, resolved.profileMeta);
|
|
49
55
|
const scenario = createScenarioRuntime({
|
|
50
56
|
seed: resolved.env.rawEnv.TESTKIT_SCENARIO_SEED,
|
|
51
57
|
});
|
|
@@ -54,12 +60,11 @@ export function defineScenarioSuite(configOrRun, maybeRun) {
|
|
|
54
60
|
try {
|
|
55
61
|
registerRuntimeContext({ env: resolved.env, http: resolved.client.rawHttp || null });
|
|
56
62
|
return run({
|
|
63
|
+
actor: actorContext.actor,
|
|
64
|
+
actors: actorContext.actors,
|
|
57
65
|
env: resolved.env,
|
|
58
|
-
req: resolved.client
|
|
66
|
+
req: resolved.client,
|
|
59
67
|
rawReq: resolved.client.raw,
|
|
60
|
-
getWithHeaders: resolved.client.getWithHeaders,
|
|
61
|
-
setupData,
|
|
62
|
-
session: setupData,
|
|
63
68
|
scenario,
|
|
64
69
|
});
|
|
65
70
|
} catch (error) {
|
|
@@ -75,105 +80,3 @@ export function defineScenarioSuite(configOrRun, maybeRun) {
|
|
|
75
80
|
},
|
|
76
81
|
};
|
|
77
82
|
}
|
|
78
|
-
|
|
79
|
-
function normalizeSuiteArgs(configOrRun, maybeRun) {
|
|
80
|
-
if (typeof configOrRun === "function") {
|
|
81
|
-
return { config: {}, run: configOrRun };
|
|
82
|
-
}
|
|
83
|
-
if (typeof maybeRun !== "function") {
|
|
84
|
-
throw new Error("suite factory requires a run callback");
|
|
85
|
-
}
|
|
86
|
-
return { config: configOrRun || {}, run: maybeRun };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function callHeaders(builder, setupData, env) {
|
|
90
|
-
if (typeof builder !== "function") return {};
|
|
91
|
-
return builder(setupData, { env }) || {};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function mergeProfileConfig(config) {
|
|
95
|
-
if (!config?.profile) return config || {};
|
|
96
|
-
|
|
97
|
-
const profile = resolveHttpProfile(config.profile) || {};
|
|
98
|
-
return {
|
|
99
|
-
...profile,
|
|
100
|
-
...config,
|
|
101
|
-
auth: config.auth ?? profile.auth ?? null,
|
|
102
|
-
headers: config.headers ?? profile.headers,
|
|
103
|
-
rawHeaders: config.rawHeaders ?? profile.rawHeaders,
|
|
104
|
-
options: config.options ?? profile.options,
|
|
105
|
-
env: config.env ?? profile.env,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function resolveRuntimeConfig(config) {
|
|
110
|
-
const resolvedConfig = mergeProfileConfig(config);
|
|
111
|
-
const env = {
|
|
112
|
-
...(resolvedConfig.env || getEnv()),
|
|
113
|
-
rawEnv: __ENV,
|
|
114
|
-
};
|
|
115
|
-
const auth = resolvedConfig.auth || null;
|
|
116
|
-
const client = createHttpClient({
|
|
117
|
-
baseUrl: env.BASE,
|
|
118
|
-
routeHeaders: env.routeParams,
|
|
119
|
-
getHeaders(setupData) {
|
|
120
|
-
return {
|
|
121
|
-
...callHeaders(auth?.headers, setupData, env),
|
|
122
|
-
...callHeaders(resolvedConfig.headers, setupData, env),
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
getRawHeaders(setupData) {
|
|
126
|
-
return callHeaders(resolvedConfig.rawHeaders, setupData, env);
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
resolvedConfig,
|
|
132
|
-
env,
|
|
133
|
-
auth,
|
|
134
|
-
client,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function formatFatalSuiteError(phase, error) {
|
|
139
|
-
if (error instanceof Error) {
|
|
140
|
-
return `Uncaught testkit suite error during ${phase}: ${error.message}`;
|
|
141
|
-
}
|
|
142
|
-
return `Uncaught testkit suite error during ${phase}: ${String(error)}`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function buildRuntimeExceptionDetail(phase, error) {
|
|
146
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
147
|
-
const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
|
|
148
|
-
const location = extractLocationFromStack(stack);
|
|
149
|
-
return {
|
|
150
|
-
kind: "runtime-exception",
|
|
151
|
-
key: location
|
|
152
|
-
? `${location.path}:${location.line}:${location.column}`
|
|
153
|
-
: `runtime-exception:${phase}:${message}`,
|
|
154
|
-
title: "Uncaught runtime exception",
|
|
155
|
-
message: `Uncaught testkit suite error during ${phase}: ${message}`,
|
|
156
|
-
location,
|
|
157
|
-
stack,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function extractLocationFromStack(stack) {
|
|
162
|
-
if (!stack) return null;
|
|
163
|
-
const matches = [...String(stack).matchAll(/(file:\/\/[^\s)]+|\/[^\s):]+):(\d+):(\d+)/g)].map(
|
|
164
|
-
(match) => ({
|
|
165
|
-
path: normalizeStackPath(match[1]),
|
|
166
|
-
line: Number(match[2]),
|
|
167
|
-
column: Number(match[3]),
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
return matches[0] || null;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function normalizeStackPath(rawPath) {
|
|
174
|
-
if (typeof rawPath !== "string") return rawPath;
|
|
175
|
-
if (rawPath.startsWith("file://")) {
|
|
176
|
-
return rawPath.slice("file://".length);
|
|
177
|
-
}
|
|
178
|
-
return rawPath;
|
|
179
|
-
}
|
|
@@ -7,16 +7,21 @@ import {
|
|
|
7
7
|
startFailureCollection,
|
|
8
8
|
} from "./checks.js";
|
|
9
9
|
import {
|
|
10
|
-
createHttpClient,
|
|
11
10
|
emitHttpTraceCollectionArtifact,
|
|
12
|
-
getEnv,
|
|
13
11
|
startHttpTraceCollection,
|
|
14
12
|
} from "./http.js";
|
|
15
13
|
import {
|
|
16
14
|
clearRuntimeContext,
|
|
17
15
|
registerRuntimeContext,
|
|
18
|
-
resolveHttpProfile,
|
|
19
16
|
} from "../../config-api/runtime.mjs";
|
|
17
|
+
import {
|
|
18
|
+
buildRuntimeExceptionDetail,
|
|
19
|
+
createSuiteActors,
|
|
20
|
+
formatFatalSuiteError,
|
|
21
|
+
mergeProfileConfig,
|
|
22
|
+
normalizeSuiteArgs,
|
|
23
|
+
resolveRuntimeConfig,
|
|
24
|
+
} from "./http-suite-runtime.js";
|
|
20
25
|
|
|
21
26
|
export function defineHttpSuite(configOrRun, maybeRun) {
|
|
22
27
|
const { config, run } = normalizeSuiteArgs(configOrRun, maybeRun);
|
|
@@ -44,18 +49,18 @@ export function defineHttpSuite(configOrRun, maybeRun) {
|
|
|
44
49
|
}
|
|
45
50
|
},
|
|
46
51
|
exec(setupData) {
|
|
47
|
-
const resolved = resolveRuntimeConfig(config);
|
|
52
|
+
const resolved = resolveRuntimeConfig(config, setupData);
|
|
53
|
+
const actorContext = createSuiteActors(setupData, resolved.client, resolved.profileMeta);
|
|
48
54
|
startFailureCollection("exec");
|
|
49
55
|
startHttpTraceCollection("exec");
|
|
50
56
|
try {
|
|
51
57
|
registerRuntimeContext({ env: resolved.env, http: resolved.client.rawHttp || null });
|
|
52
58
|
return run({
|
|
59
|
+
actor: actorContext.actor,
|
|
60
|
+
actors: actorContext.actors,
|
|
53
61
|
env: resolved.env,
|
|
54
|
-
req: resolved.client
|
|
62
|
+
req: resolved.client,
|
|
55
63
|
rawReq: resolved.client.raw,
|
|
56
|
-
getWithHeaders: resolved.client.getWithHeaders,
|
|
57
|
-
setupData,
|
|
58
|
-
session: setupData,
|
|
59
64
|
});
|
|
60
65
|
} catch (error) {
|
|
61
66
|
recordFailureDetail(buildRuntimeExceptionDetail("exec", error));
|
|
@@ -69,102 +74,3 @@ export function defineHttpSuite(configOrRun, maybeRun) {
|
|
|
69
74
|
},
|
|
70
75
|
};
|
|
71
76
|
}
|
|
72
|
-
|
|
73
|
-
function normalizeSuiteArgs(configOrRun, maybeRun) {
|
|
74
|
-
if (typeof configOrRun === "function") {
|
|
75
|
-
return { config: {}, run: configOrRun };
|
|
76
|
-
}
|
|
77
|
-
if (typeof maybeRun !== "function") {
|
|
78
|
-
throw new Error("suite factory requires a run callback");
|
|
79
|
-
}
|
|
80
|
-
return { config: configOrRun || {}, run: maybeRun };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function callHeaders(builder, setupData, env) {
|
|
84
|
-
if (typeof builder !== "function") return {};
|
|
85
|
-
return builder(setupData, { env }) || {};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function mergeProfileConfig(config) {
|
|
89
|
-
if (!config?.profile) return config || {};
|
|
90
|
-
|
|
91
|
-
const profile = resolveHttpProfile(config.profile) || {};
|
|
92
|
-
return {
|
|
93
|
-
...profile,
|
|
94
|
-
...config,
|
|
95
|
-
auth: config.auth ?? profile.auth ?? null,
|
|
96
|
-
headers: config.headers ?? profile.headers,
|
|
97
|
-
rawHeaders: config.rawHeaders ?? profile.rawHeaders,
|
|
98
|
-
options: config.options ?? profile.options,
|
|
99
|
-
env: config.env ?? profile.env,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function resolveRuntimeConfig(config) {
|
|
104
|
-
const resolvedConfig = mergeProfileConfig(config);
|
|
105
|
-
const env = {
|
|
106
|
-
...(resolvedConfig.env || getEnv()),
|
|
107
|
-
rawEnv: __ENV,
|
|
108
|
-
};
|
|
109
|
-
const auth = resolvedConfig.auth || null;
|
|
110
|
-
const client = createHttpClient({
|
|
111
|
-
baseUrl: env.BASE,
|
|
112
|
-
routeHeaders: env.routeParams,
|
|
113
|
-
getHeaders(setupData) {
|
|
114
|
-
return {
|
|
115
|
-
...callHeaders(auth?.headers, setupData, env),
|
|
116
|
-
...callHeaders(resolvedConfig.headers, setupData, env),
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
getRawHeaders(setupData) {
|
|
120
|
-
return callHeaders(resolvedConfig.rawHeaders, setupData, env);
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
resolvedConfig,
|
|
126
|
-
env,
|
|
127
|
-
auth,
|
|
128
|
-
client,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function formatFatalSuiteError(phase, error) {
|
|
133
|
-
if (error instanceof Error) {
|
|
134
|
-
return `Uncaught testkit suite error during ${phase}: ${error.message}`;
|
|
135
|
-
}
|
|
136
|
-
return `Uncaught testkit suite error during ${phase}: ${String(error)}`;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function buildRuntimeExceptionDetail(phase, error) {
|
|
140
|
-
const message =
|
|
141
|
-
error instanceof Error ? error.message : String(error);
|
|
142
|
-
const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
|
|
143
|
-
const location = extractLocationFromStack(stack);
|
|
144
|
-
return {
|
|
145
|
-
kind: "runtime-exception",
|
|
146
|
-
key: location ? `${location.path}:${location.line}:${location.column}` : `runtime-exception:${phase}:${message}`,
|
|
147
|
-
title: "Uncaught runtime exception",
|
|
148
|
-
message: `Uncaught testkit suite error during ${phase}: ${message}`,
|
|
149
|
-
location,
|
|
150
|
-
stack,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function extractLocationFromStack(stack) {
|
|
155
|
-
if (!stack) return null;
|
|
156
|
-
const matches = [...String(stack).matchAll(/(file:\/\/[^\s)]+|\/[^\s):]+):(\d+):(\d+)/g)].map((match) => ({
|
|
157
|
-
path: normalizeStackPath(match[1]),
|
|
158
|
-
line: Number(match[2]),
|
|
159
|
-
column: Number(match[3]),
|
|
160
|
-
}));
|
|
161
|
-
return matches[0] || null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function normalizeStackPath(rawPath) {
|
|
165
|
-
if (typeof rawPath !== "string") return rawPath;
|
|
166
|
-
if (rawPath.startsWith("file://")) {
|
|
167
|
-
return rawPath.slice("file://".length);
|
|
168
|
-
}
|
|
169
|
-
return rawPath;
|
|
170
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.82",
|
|
4
4
|
"description": "Browser bridge helpers for testkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@elench/testkit-protocol": "0.1.
|
|
25
|
+
"@elench/testkit-protocol": "0.1.82"
|
|
26
26
|
},
|
|
27
27
|
"private": false
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.82",
|
|
4
4
|
"description": "CLI for discovering and running local HTTP, DAL, and Playwright test suites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@babel/code-frame": "^7.29.0",
|
|
84
|
-
"@elench/next-analysis": "0.1.
|
|
85
|
-
"@elench/testkit-bridge": "0.1.
|
|
86
|
-
"@elench/testkit-protocol": "0.1.
|
|
87
|
-
"@elench/ts-analysis": "0.1.
|
|
84
|
+
"@elench/next-analysis": "0.1.82",
|
|
85
|
+
"@elench/testkit-bridge": "0.1.82",
|
|
86
|
+
"@elench/testkit-protocol": "0.1.82",
|
|
87
|
+
"@elench/ts-analysis": "0.1.82",
|
|
88
88
|
"@oclif/core": "^4.10.6",
|
|
89
89
|
"esbuild": "^0.25.11",
|
|
90
90
|
"execa": "^9.5.0",
|