spana-test 0.0.1 → 0.1.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/.agents/skills/spana-testing/SKILL.md +301 -0
- package/README.md +276 -0
- package/dist/agent/index.d.ts +81 -0
- package/dist/agent/index.js +21 -0
- package/dist/allure-PTTVORQ6.js +124 -0
- package/dist/allure-PTTVORQ6.js.map +1 -0
- package/dist/android-PAPJJWVN.js +34 -0
- package/dist/android-PAPJJWVN.js.map +1 -0
- package/dist/chunk-3FSZNKEF.js +62 -0
- package/dist/chunk-3FSZNKEF.js.map +1 -0
- package/dist/chunk-53MUJUJY.js +113 -0
- package/dist/chunk-53MUJUJY.js.map +1 -0
- package/dist/chunk-5XO6S7AI.js +134 -0
- package/dist/chunk-5XO6S7AI.js.map +1 -0
- package/dist/chunk-BZRLA4Z3.js +82 -0
- package/dist/chunk-BZRLA4Z3.js.map +1 -0
- package/dist/{chunk-PF7V37UD.js → chunk-CKJQX73M.js} +897 -845
- package/dist/chunk-CKJQX73M.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/{chunk-HKDZMXD7.js → chunk-GZK22EIE.js} +76 -102
- package/dist/chunk-GZK22EIE.js.map +1 -0
- package/dist/chunk-PANFRTIU.js +310 -0
- package/dist/chunk-PANFRTIU.js.map +1 -0
- package/dist/chunk-PWEOJKUF.js +473 -0
- package/dist/chunk-PWEOJKUF.js.map +1 -0
- package/dist/chunk-RJ5VPHVX.js +127 -0
- package/dist/chunk-RJ5VPHVX.js.map +1 -0
- package/dist/chunk-RK4Z6C7M.js +248 -0
- package/dist/chunk-RK4Z6C7M.js.map +1 -0
- package/dist/chunk-U564GCO2.js +259 -0
- package/dist/chunk-U564GCO2.js.map +1 -0
- package/dist/chunk-V62HFH6E.js +269 -0
- package/dist/chunk-V62HFH6E.js.map +1 -0
- package/dist/chunk-VDWWIVM6.js +303 -0
- package/dist/chunk-VDWWIVM6.js.map +1 -0
- package/dist/{discover-4EZKZ5RO.js → chunk-WIJYK22K.js} +12 -5
- package/dist/{discover-4EZKZ5RO.js.map → chunk-WIJYK22K.js.map} +1 -1
- package/dist/cli.js +135 -17
- package/dist/cli.js.map +1 -1
- package/dist/compiler-G75RIIYS.js +312 -0
- package/dist/compiler-G75RIIYS.js.map +1 -0
- package/dist/config-Dg9O0rcQ.d.ts +219 -0
- package/dist/config-loader-JJ5RPP53.js +9 -0
- package/dist/config-loader-JJ5RPP53.js.map +1 -0
- package/dist/console-FV4RJPO4.js +132 -0
- package/dist/console-FV4RJPO4.js.map +1 -0
- package/dist/discover-RWBKI5IB.js +14 -0
- package/dist/discover-RWBKI5IB.js.map +1 -0
- package/dist/element-CGteXiXB.d.ts +23 -0
- package/dist/flow-D-_tlLpp.d.ts +99 -0
- package/dist/gherkin/steps.d.ts +32 -0
- package/dist/gherkin/steps.js +39 -0
- package/dist/gherkin/steps.js.map +1 -0
- package/dist/{html-OGRQ5NIX.js → html-JP2HBIJQ.js} +54 -20
- package/dist/html-JP2HBIJQ.js.map +1 -0
- package/dist/index.d.ts +4 -157
- package/dist/index.js +36 -165
- package/dist/index.js.map +1 -1
- package/dist/init-command-CELKL2CX.js +105 -0
- package/dist/init-command-CELKL2CX.js.map +1 -0
- package/dist/installer-R6NX7BYQ.js +20 -0
- package/dist/installer-R6NX7BYQ.js.map +1 -0
- package/dist/ios-ZZU6DHH7.js +48 -0
- package/dist/ios-ZZU6DHH7.js.map +1 -0
- package/dist/{json-3TZD6FI5.js → json-JMRPUVY2.js} +2 -2
- package/dist/{junit-ES66OYVX.js → junit-UDY5JG22.js} +14 -3
- package/dist/junit-UDY5JG22.js.map +1 -0
- package/dist/provider-CUWPULGC.js +10 -0
- package/dist/provider-CUWPULGC.js.map +1 -0
- package/dist/redact-IDA3C4UH.js +77 -0
- package/dist/redact-IDA3C4UH.js.map +1 -0
- package/dist/runner-QEF6PJOE.js +20 -0
- package/dist/runner-QEF6PJOE.js.map +1 -0
- package/dist/server-MMK7PZIH.js +505 -0
- package/dist/server-MMK7PZIH.js.map +1 -0
- package/dist/session-FBJABNXL.js +16 -0
- package/dist/session-FBJABNXL.js.map +1 -0
- package/dist/studio-command-CDVPREMG.js +24 -0
- package/dist/studio-command-CDVPREMG.js.map +1 -0
- package/dist/test-command-SB5KYPQI.js +1929 -0
- package/dist/test-command-SB5KYPQI.js.map +1 -0
- package/dist/validator-CFQ55NUQ.js +13 -0
- package/dist/validator-CFQ55NUQ.js.map +1 -0
- package/package.json +43 -5
- package/studio-dist/assets/index-CPdpC9i-.css +1 -0
- package/studio-dist/assets/index-L1Wd0vop.js +183 -0
- package/studio-dist/index.html +13 -0
- package/dist/chunk-HKDZMXD7.js.map +0 -1
- package/dist/chunk-PF7V37UD.js.map +0 -1
- package/dist/chunk-Y7MNYLGH.js +0 -64
- package/dist/chunk-Y7MNYLGH.js.map +0 -1
- package/dist/console-ZH3SUKUO.js +0 -71
- package/dist/console-ZH3SUKUO.js.map +0 -1
- package/dist/html-OGRQ5NIX.js.map +0 -1
- package/dist/junit-ES66OYVX.js.map +0 -1
- package/dist/runner-NGLCXD2E.js +0 -12
- package/dist/session-NWNZWWNI.js +0 -122
- package/dist/session-NWNZWWNI.js.map +0 -1
- package/dist/test-command-F3AEHF2E.js +0 -636
- package/dist/test-command-F3AEHF2E.js.map +0 -1
- package/dist/validator-LHN66ZH7.js +0 -33
- package/dist/validator-LHN66ZH7.js.map +0 -1
- /package/dist/{runner-NGLCXD2E.js.map → agent/index.js.map} +0 -0
- /package/dist/{json-3TZD6FI5.js.map → json-JMRPUVY2.js.map} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
1
|
import {
|
|
3
|
-
listAndroidDevices
|
|
2
|
+
listAndroidDevices
|
|
3
|
+
} from "./chunk-GZK22EIE.js";
|
|
4
|
+
import {
|
|
4
5
|
listBootedSimulators
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-V62HFH6E.js";
|
|
6
7
|
|
|
7
8
|
// src/device/discover.ts
|
|
8
9
|
function discoverDevices(platforms) {
|
|
@@ -46,8 +47,14 @@ function firstDeviceForPlatform(platform) {
|
|
|
46
47
|
const devices = discoverDevices([platform]);
|
|
47
48
|
return devices[0] ?? null;
|
|
48
49
|
}
|
|
50
|
+
function findDeviceById(id) {
|
|
51
|
+
const devices = discoverDevices(["web", "android", "ios"]);
|
|
52
|
+
return devices.find((d) => d.id === id) ?? null;
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
export {
|
|
50
56
|
discoverDevices,
|
|
51
|
-
firstDeviceForPlatform
|
|
57
|
+
firstDeviceForPlatform,
|
|
58
|
+
findDeviceById
|
|
52
59
|
};
|
|
53
|
-
//# sourceMappingURL=
|
|
60
|
+
//# sourceMappingURL=chunk-WIJYK22K.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/device/discover.ts"],"sourcesContent":["import type { Platform } from \"../schemas/selector.js\";\nimport { listAndroidDevices } from \"./android.js\";\nimport { listBootedSimulators } from \"./ios.js\";\n\nexport interface DiscoveredDevice {\n platform: Platform;\n id: string;\n name: string;\n type: \"emulator\" | \"simulator\" | \"device\" | \"browser\";\n state: string;\n}\n\n/** Discover all available devices across requested platforms */\nexport function discoverDevices(platforms: Platform[]): DiscoveredDevice[] {\n const devices: DiscoveredDevice[] = [];\n\n if (platforms.includes(\"web\")) {\n devices.push({\n platform: \"web\",\n id: \"playwright-chromium\",\n name: \"Chromium (Playwright)\",\n type: \"browser\",\n state: \"available\",\n });\n }\n\n if (platforms.includes(\"android\")) {\n for (const d of listAndroidDevices()) {\n if (d.state === \"device\") {\n devices.push({\n platform: \"android\",\n id: d.serial,\n name: d.serial,\n type: d.type === \"emulator\" ? \"emulator\" : \"device\",\n state: d.state,\n });\n }\n }\n }\n\n if (platforms.includes(\"ios\")) {\n for (const s of listBootedSimulators()) {\n devices.push({\n platform: \"ios\",\n id: s.udid,\n name: `${s.name} (${s.runtime})`,\n type: \"simulator\",\n state: s.state,\n });\n }\n }\n\n return devices;\n}\n\n/** Get first available device for a platform */\nexport function firstDeviceForPlatform(platform: Platform): DiscoveredDevice | null {\n const devices = discoverDevices([platform]);\n return devices[0] ?? null;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/device/discover.ts"],"sourcesContent":["import type { Platform } from \"../schemas/selector.js\";\nimport { listAndroidDevices } from \"./android.js\";\nimport { listBootedSimulators } from \"./ios.js\";\n\nexport interface DiscoveredDevice {\n platform: Platform;\n id: string;\n name: string;\n type: \"emulator\" | \"simulator\" | \"device\" | \"browser\";\n state: string;\n}\n\n/** Discover all available devices across requested platforms */\nexport function discoverDevices(platforms: Platform[]): DiscoveredDevice[] {\n const devices: DiscoveredDevice[] = [];\n\n if (platforms.includes(\"web\")) {\n devices.push({\n platform: \"web\",\n id: \"playwright-chromium\",\n name: \"Chromium (Playwright)\",\n type: \"browser\",\n state: \"available\",\n });\n }\n\n if (platforms.includes(\"android\")) {\n for (const d of listAndroidDevices()) {\n if (d.state === \"device\") {\n devices.push({\n platform: \"android\",\n id: d.serial,\n name: d.serial,\n type: d.type === \"emulator\" ? \"emulator\" : \"device\",\n state: d.state,\n });\n }\n }\n }\n\n if (platforms.includes(\"ios\")) {\n for (const s of listBootedSimulators()) {\n devices.push({\n platform: \"ios\",\n id: s.udid,\n name: `${s.name} (${s.runtime})`,\n type: \"simulator\",\n state: s.state,\n });\n }\n }\n\n return devices;\n}\n\n/** Get first available device for a platform */\nexport function firstDeviceForPlatform(platform: Platform): DiscoveredDevice | null {\n const devices = discoverDevices([platform]);\n return devices[0] ?? null;\n}\n\n/** Find a specific device by ID across all platforms */\nexport function findDeviceById(id: string): DiscoveredDevice | null {\n const devices = discoverDevices([\"web\", \"android\", \"ios\"]);\n return devices.find((d) => d.id === id) ?? null;\n}\n"],"mappings":";;;;;;;;AAaO,SAAS,gBAAgB,WAA2C;AACzE,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,6 +9,18 @@ if (command === "test") {
|
|
|
10
9
|
let reporter;
|
|
11
10
|
let configPath;
|
|
12
11
|
let flowPath;
|
|
12
|
+
let retries;
|
|
13
|
+
let device;
|
|
14
|
+
let driver;
|
|
15
|
+
let appiumUrl;
|
|
16
|
+
let capsPath;
|
|
17
|
+
let capsJson;
|
|
18
|
+
let noProviderReporting = false;
|
|
19
|
+
let validateConfigOnly = false;
|
|
20
|
+
let shard;
|
|
21
|
+
let bail;
|
|
22
|
+
let debugOnFailure = false;
|
|
23
|
+
let quiet = false;
|
|
13
24
|
for (let i = 1; i < args.length; i++) {
|
|
14
25
|
const arg = args[i];
|
|
15
26
|
if (arg === "--platform" && args[i + 1]) {
|
|
@@ -22,38 +33,93 @@ if (command === "test") {
|
|
|
22
33
|
reporter = args[++i];
|
|
23
34
|
} else if (arg === "--config" && args[i + 1]) {
|
|
24
35
|
configPath = args[++i];
|
|
36
|
+
} else if (arg === "--retries" && args[i + 1]) {
|
|
37
|
+
retries = parseInt(args[++i], 10);
|
|
38
|
+
} else if (arg === "--device" && args[i + 1]) {
|
|
39
|
+
device = args[++i];
|
|
40
|
+
} else if (arg === "--driver" && args[i + 1]) {
|
|
41
|
+
driver = args[++i];
|
|
42
|
+
} else if (arg === "--appium-url" && args[i + 1]) {
|
|
43
|
+
appiumUrl = args[++i];
|
|
44
|
+
} else if (arg === "--caps" && args[i + 1]) {
|
|
45
|
+
capsPath = args[++i];
|
|
46
|
+
} else if (arg === "--caps-json" && args[i + 1]) {
|
|
47
|
+
capsJson = args[++i];
|
|
48
|
+
} else if (arg === "--no-provider-reporting") {
|
|
49
|
+
noProviderReporting = true;
|
|
50
|
+
} else if (arg === "--validate-config") {
|
|
51
|
+
validateConfigOnly = true;
|
|
52
|
+
} else if (arg === "--shard" && args[i + 1]) {
|
|
53
|
+
const [currentText, totalText] = args[++i].split("/");
|
|
54
|
+
const current = Number(currentText);
|
|
55
|
+
const total = Number(totalText);
|
|
56
|
+
if (!Number.isInteger(current) || !Number.isInteger(total) || current < 1 || total < 1 || current > total) {
|
|
57
|
+
console.log(
|
|
58
|
+
"Invalid --shard format. Use --shard <current>/<total> with 1 <= current <= total."
|
|
59
|
+
);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
shard = { current, total };
|
|
63
|
+
} else if (arg === "--bail" && args[i + 1]) {
|
|
64
|
+
bail = Number.parseInt(args[++i], 10);
|
|
65
|
+
if (!Number.isInteger(bail) || bail < 1) {
|
|
66
|
+
console.log("Invalid --bail value. Use --bail <n> with n >= 1.");
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
} else if (arg === "--debug-on-failure") {
|
|
70
|
+
debugOnFailure = true;
|
|
71
|
+
} else if (arg === "--quiet" || arg === "-q") {
|
|
72
|
+
quiet = true;
|
|
25
73
|
} else if (!arg.startsWith("--")) {
|
|
26
74
|
flowPath = arg;
|
|
27
75
|
}
|
|
28
76
|
}
|
|
29
|
-
const { runTestCommand } = await import("./test-command-
|
|
77
|
+
const { runTestCommand } = await import("./test-command-SB5KYPQI.js");
|
|
30
78
|
const success = await runTestCommand({
|
|
31
79
|
platforms,
|
|
32
80
|
tags,
|
|
33
81
|
grep,
|
|
34
82
|
reporter,
|
|
35
83
|
configPath,
|
|
36
|
-
flowPath
|
|
84
|
+
flowPath,
|
|
85
|
+
retries,
|
|
86
|
+
device,
|
|
87
|
+
driver,
|
|
88
|
+
appiumUrl,
|
|
89
|
+
capsPath,
|
|
90
|
+
capsJson,
|
|
91
|
+
noProviderReporting,
|
|
92
|
+
validateConfigOnly,
|
|
93
|
+
shard,
|
|
94
|
+
bail,
|
|
95
|
+
debugOnFailure,
|
|
96
|
+
quiet
|
|
37
97
|
});
|
|
38
98
|
process.exit(success ? 0 : 1);
|
|
39
99
|
} else if (command === "hierarchy" || command === "selectors") {
|
|
40
100
|
let platform = "web";
|
|
41
101
|
let pretty = false;
|
|
102
|
+
let configPath;
|
|
42
103
|
for (let i = 1; i < args.length; i++) {
|
|
43
104
|
if (args[i] === "--platform" && args[i + 1]) platform = args[++i];
|
|
44
105
|
if (args[i] === "--pretty") pretty = true;
|
|
106
|
+
if (args[i] === "--config" && args[i + 1]) configPath = args[++i];
|
|
45
107
|
}
|
|
46
|
-
const { resolve } = await import("path");
|
|
47
108
|
let config = {};
|
|
48
109
|
try {
|
|
49
|
-
const
|
|
50
|
-
config =
|
|
51
|
-
} catch {
|
|
110
|
+
const { loadConfig } = await import("./config-loader-JJ5RPP53.js");
|
|
111
|
+
config = (await loadConfig({ configPath, allowMissing: true })).config;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.log(error instanceof Error ? error.message : String(error));
|
|
114
|
+
process.exit(1);
|
|
52
115
|
}
|
|
53
|
-
const { connect } = await import("./session-
|
|
116
|
+
const { connect } = await import("./session-FBJABNXL.js");
|
|
54
117
|
const session = await connect({
|
|
55
118
|
platform,
|
|
56
119
|
baseUrl: config.apps?.web?.url,
|
|
120
|
+
browser: config.execution?.web?.browser,
|
|
121
|
+
headless: config.execution?.web?.headless,
|
|
122
|
+
storageState: config.execution?.web?.storageState,
|
|
57
123
|
packageName: config.apps?.android?.packageName,
|
|
58
124
|
bundleId: config.apps?.ios?.bundleId
|
|
59
125
|
});
|
|
@@ -67,18 +133,59 @@ if (command === "test") {
|
|
|
67
133
|
await session.disconnect();
|
|
68
134
|
} else if (command === "validate") {
|
|
69
135
|
const path = args[1] ?? "./flows";
|
|
70
|
-
const {
|
|
71
|
-
const
|
|
72
|
-
const paths = await discoverFlows(path);
|
|
73
|
-
const errors = await validateFlows(paths);
|
|
136
|
+
const { validateProject } = await import("./validator-CFQ55NUQ.js");
|
|
137
|
+
const errors = await validateProject(path);
|
|
74
138
|
if (errors.length === 0) {
|
|
139
|
+
const { discoverFlows } = await import("./runner-QEF6PJOE.js");
|
|
140
|
+
const paths = await discoverFlows(path);
|
|
75
141
|
console.log(`\u2713 ${paths.length} flow(s) valid`);
|
|
76
142
|
} else {
|
|
77
143
|
for (const e of errors) console.log(`\u2717 ${e.file}: ${e.error}`);
|
|
78
144
|
process.exit(1);
|
|
79
145
|
}
|
|
146
|
+
} else if (command === "validate-config") {
|
|
147
|
+
let configPath;
|
|
148
|
+
for (let i = 1; i < args.length; i++) {
|
|
149
|
+
const arg = args[i];
|
|
150
|
+
if (arg === "--config" && args[i + 1]) {
|
|
151
|
+
configPath = args[++i];
|
|
152
|
+
} else if (!arg.startsWith("--")) {
|
|
153
|
+
configPath = arg;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const { loadConfig } = await import("./config-loader-JJ5RPP53.js");
|
|
157
|
+
try {
|
|
158
|
+
const result = await loadConfig({ configPath });
|
|
159
|
+
console.log(`\u2713 Config valid (${result.configPath})`);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.log(error instanceof Error ? error.message : String(error));
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
} else if (command === "studio") {
|
|
165
|
+
let port = 4400;
|
|
166
|
+
let open = true;
|
|
167
|
+
let configPath;
|
|
168
|
+
for (let i = 1; i < args.length; i++) {
|
|
169
|
+
if (args[i] === "--port" && args[i + 1]) port = Number(args[++i]);
|
|
170
|
+
if (args[i] === "--no-open") open = false;
|
|
171
|
+
if (args[i] === "--config" && args[i + 1]) configPath = args[++i];
|
|
172
|
+
}
|
|
173
|
+
let config = {};
|
|
174
|
+
try {
|
|
175
|
+
const { loadConfig } = await import("./config-loader-JJ5RPP53.js");
|
|
176
|
+
config = (await loadConfig({ configPath, allowMissing: true })).config;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.log(error instanceof Error ? error.message : String(error));
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
const { runStudioCommand } = await import("./studio-command-CDVPREMG.js");
|
|
182
|
+
await runStudioCommand({ port, open, config });
|
|
183
|
+
} else if (command === "init") {
|
|
184
|
+
const force = args.includes("--force");
|
|
185
|
+
const { runInitCommand } = await import("./init-command-CELKL2CX.js");
|
|
186
|
+
await runInitCommand({ force });
|
|
80
187
|
} else if (command === "devices") {
|
|
81
|
-
const { discoverDevices } = await import("./discover-
|
|
188
|
+
const { discoverDevices } = await import("./discover-RWBKI5IB.js");
|
|
82
189
|
const devices = discoverDevices(["web", "android", "ios"]);
|
|
83
190
|
if (devices.length === 0) {
|
|
84
191
|
console.log("No devices found.");
|
|
@@ -97,19 +204,30 @@ if (command === "test") {
|
|
|
97
204
|
console.log(" spana hierarchy --platform <p> Dump element hierarchy as JSON");
|
|
98
205
|
console.log(" spana selectors --platform <p> List actionable elements with suggested selectors");
|
|
99
206
|
console.log(" spana validate [path] Validate flow files without device connection");
|
|
207
|
+
console.log(" spana validate-config [path] Validate spana.config.ts without running flows");
|
|
208
|
+
console.log(" spana studio Launch Spana Studio UI");
|
|
209
|
+
console.log(" spana init Initialize a new spana project");
|
|
100
210
|
console.log(" spana devices List connected devices across platforms");
|
|
101
211
|
console.log(" spana version Show version");
|
|
102
212
|
console.log("");
|
|
103
213
|
console.log("Options:");
|
|
104
|
-
console.log(
|
|
105
|
-
" --platform web,android,ios Platforms to test (default: spana.config.ts or web)"
|
|
106
|
-
);
|
|
214
|
+
console.log(" --platform web,android,ios Platforms to test (default: spana.config.ts or web)");
|
|
107
215
|
console.log(" --tag smoke,auth Filter by tags");
|
|
108
216
|
console.log(" --grep login Filter by name pattern");
|
|
109
217
|
console.log(
|
|
110
218
|
" --reporter console|json|junit Reporter format (default: spana.config.ts or console)"
|
|
111
219
|
);
|
|
220
|
+
console.log(" --retries <n> Retry failed flows n times (flake detection)");
|
|
221
|
+
console.log(" --shard <current>/<total> Distribute flows across CI jobs");
|
|
222
|
+
console.log(" --bail <n> Abort after N failures");
|
|
223
|
+
console.log(" --debug-on-failure Open an interactive REPL on the first failed flow");
|
|
224
|
+
console.log(" --quiet, -q Only show failures and final summary");
|
|
225
|
+
console.log(" --device <id> Target a specific device by ID");
|
|
226
|
+
console.log(" --validate-config Validate config and exit");
|
|
112
227
|
console.log(" --config path Config file path");
|
|
113
228
|
console.log(" --pretty Pretty-print JSON output (hierarchy command)");
|
|
229
|
+
console.log(" --port <number> Studio port (default: 4400)");
|
|
230
|
+
console.log(" --no-open Don't open browser (studio command)");
|
|
231
|
+
console.log(" --force Overwrite existing files (init command)");
|
|
114
232
|
}
|
|
115
233
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/index.ts"],"sourcesContent":["import type { Platform } from \"../schemas/selector.js\";\n\nconst args = process.argv.slice(2);\nconst command = args[0];\n\nif (command === \"test\") {\n const platforms: Platform[] = [];\n let tags: string[] | undefined;\n let grep: string | undefined;\n let reporter: string | undefined;\n let configPath: string | undefined;\n let flowPath: string | undefined;\n\n for (let i = 1; i < args.length; i++) {\n const arg = args[i]!;\n if (arg === \"--platform\" && args[i + 1]) {\n platforms.push(...(args[++i]!.split(\",\") as Platform[]));\n } else if (arg === \"--tag\" && args[i + 1]) {\n tags = args[++i]!.split(\",\");\n } else if (arg === \"--grep\" && args[i + 1]) {\n grep = args[++i];\n } else if (arg === \"--reporter\" && args[i + 1]) {\n reporter = args[++i]!;\n } else if (arg === \"--config\" && args[i + 1]) {\n configPath = args[++i];\n } else if (!arg.startsWith(\"--\")) {\n flowPath = arg;\n }\n }\n\n const { runTestCommand } = await import(\"./test-command.js\");\n const success = await runTestCommand({\n platforms,\n tags,\n grep,\n reporter,\n configPath,\n flowPath,\n });\n process.exit(success ? 0 : 1);\n} else if (command === \"hierarchy\" || command === \"selectors\") {\n let platform: Platform = \"web\";\n let pretty = false;\n for (let i = 1; i < args.length; i++) {\n if (args[i] === \"--platform\" && args[i + 1]) platform = args[++i] as Platform;\n if (args[i] === \"--pretty\") pretty = true;\n }\n // Load config for baseUrl/packageName/bundleId\n const { resolve } = await import(\"node:path\");\n let config: Record<string, any> = {};\n try {\n const mod = await import(resolve(\"spana.config.ts\"));\n config = mod.default ?? {};\n } catch { /* no config */ }\n const { connect } = await import(\"../agent/session.js\");\n const session = await connect({\n platform,\n baseUrl: config.apps?.web?.url,\n packageName: config.apps?.android?.packageName,\n bundleId: config.apps?.ios?.bundleId,\n });\n if (command === \"hierarchy\") {\n const root = await session.hierarchy();\n console.log(pretty ? JSON.stringify(root, null, 2) : JSON.stringify(root));\n } else {\n const elements = await session.selectors();\n console.log(JSON.stringify(elements, null, 2));\n }\n await session.disconnect();\n} else if (command === \"validate\") {\n const path = args[1] ?? \"./flows\";\n const { discoverFlows } = await import(\"../core/runner.js\");\n const { validateFlows } = await import(\"../core/validator.js\");\n const paths = await discoverFlows(path);\n const errors = await validateFlows(paths);\n if (errors.length === 0) {\n console.log(`✓ ${paths.length} flow(s) valid`);\n } else {\n for (const e of errors) console.log(`✗ ${e.file}: ${e.error}`);\n process.exit(1);\n }\n} else if (command === \"devices\") {\n const { discoverDevices } = await import(\"../device/discover.js\");\n const devices = discoverDevices([\"web\", \"android\", \"ios\"]);\n if (devices.length === 0) {\n console.log(\"No devices found.\");\n } else {\n for (const d of devices) {\n console.log(` ${d.platform.padEnd(8)} ${d.name.padEnd(30)} ${d.type.padEnd(10)} ${d.state}`);\n }\n }\n} else if (\n command === \"version\" ||\n args.includes(\"--version\") ||\n args.includes(\"-v\")\n) {\n console.log(\"spana v0.0.1\");\n} else {\n console.log(\"spana — TypeScript-native E2E testing for React Native + Web\");\n console.log(\"\");\n console.log(\"Commands:\");\n console.log(\" spana test [path] Run test flows\");\n console.log(\" spana hierarchy --platform <p> Dump element hierarchy as JSON\");\n console.log(\" spana selectors --platform <p> List actionable elements with suggested selectors\");\n console.log(\" spana validate [path] Validate flow files without device connection\");\n console.log(\" spana devices List connected devices across platforms\");\n console.log(\" spana version Show version\");\n console.log(\"\");\n console.log(\"Options:\");\n console.log(\n \" --platform web,android,ios Platforms to test (default: spana.config.ts or web)\",\n );\n console.log(\" --tag smoke,auth Filter by tags\");\n console.log(\" --grep login Filter by name pattern\");\n console.log(\n \" --reporter console|json|junit Reporter format (default: spana.config.ts or console)\",\n );\n console.log(\" --config path Config file path\");\n console.log(\" --pretty Pretty-print JSON output (hierarchy command)\");\n}\n"],"mappings":";;;AAEA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AAEtB,IAAI,YAAY,QAAQ;AACtB,QAAM,YAAwB,CAAC;AAC/B,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,QAAQ,gBAAgB,KAAK,IAAI,CAAC,GAAG;AACvC,gBAAU,KAAK,GAAI,KAAK,EAAE,CAAC,EAAG,MAAM,GAAG,CAAgB;AAAA,IACzD,WAAW,QAAQ,WAAW,KAAK,IAAI,CAAC,GAAG;AACzC,aAAO,KAAK,EAAE,CAAC,EAAG,MAAM,GAAG;AAAA,IAC7B,WAAW,QAAQ,YAAY,KAAK,IAAI,CAAC,GAAG;AAC1C,aAAO,KAAK,EAAE,CAAC;AAAA,IACjB,WAAW,QAAQ,gBAAgB,KAAK,IAAI,CAAC,GAAG;AAC9C,iBAAW,KAAK,EAAE,CAAC;AAAA,IACrB,WAAW,QAAQ,cAAc,KAAK,IAAI,CAAC,GAAG;AAC5C,mBAAa,KAAK,EAAE,CAAC;AAAA,IACvB,WAAW,CAAC,IAAI,WAAW,IAAI,GAAG;AAChC,iBAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,EAAE,eAAe,IAAI,MAAM,OAAO,4BAAmB;AAC3D,QAAM,UAAU,MAAM,eAAe;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,UAAQ,KAAK,UAAU,IAAI,CAAC;AAC9B,WAAW,YAAY,eAAe,YAAY,aAAa;AAC7D,MAAI,WAAqB;AACzB,MAAI,SAAS;AACb,WAAS,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eAAW,KAAK,OAAQ,SAAQ,IAAI,UAAK,EAAE,IAAI,KAAK,EAAE,KAAK,EAAE;AAC7D,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,WAAW,YAAY,WAAW;AAChC,QAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,wBAAuB;AAChE,QAAM,UAAU,gBAAgB,CAAC,OAAO,WAAW,KAAK,CAAC;AACzD,MAAI,QAAQ,WAAW,GAAG;AACxB,YAAQ,IAAI,mBAAmB;AAAA,EACjC,OAAO;AACL,eAAW,KAAK,SAAS;AACvB,cAAQ,IAAI,KAAK,EAAE,SAAS,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE;AAAA,IAC9F;AAAA,EACF;AACF,WACE,YAAY,aACZ,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,IAAI,GAClB;AACA,UAAQ,IAAI,cAAc;AAC5B,OAAO;AACL,UAAQ,IAAI,mEAA8D;AAC1E,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,WAAW;AACvB,UAAQ,IAAI,iDAAiD;AAC7D,UAAQ,IAAI,iEAAiE;AAC7E,UAAQ,IAAI,oFAAoF;AAChG,UAAQ,IAAI,gFAAgF;AAC5F,UAAQ,IAAI,0EAA0E;AACtF,UAAQ,IAAI,+CAA+C;AAC3D,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,UAAU;AACtB,UAAQ;AAAA,IACN;AAAA,EACF;AACA,UAAQ,IAAI,6CAA6C;AACzD,UAAQ,IAAI,qDAAqD;AACjE,UAAQ;AAAA,IACN;AAAA,EACF;AACA,UAAQ,IAAI,+CAA+C;AAC3D,UAAQ,IAAI,2EAA2E;AACzF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli/index.ts"],"sourcesContent":["import type { Platform } from \"../schemas/selector.js\";\n\nconst args = process.argv.slice(2);\nconst command = args[0];\n\nif (command === \"test\") {\n const platforms: Platform[] = [];\n let tags: string[] | undefined;\n let grep: string | undefined;\n let reporter: string | undefined;\n let configPath: string | undefined;\n let flowPath: string | undefined;\n let retries: number | undefined;\n let device: string | undefined;\n let driver: \"local\" | \"appium\" | undefined;\n let appiumUrl: string | undefined;\n let capsPath: string | undefined;\n let capsJson: string | undefined;\n let noProviderReporting = false;\n let validateConfigOnly = false;\n let shard: { current: number; total: number } | undefined;\n let bail: number | undefined;\n let debugOnFailure = false;\n let quiet = false;\n\n for (let i = 1; i < args.length; i++) {\n const arg = args[i]!;\n if (arg === \"--platform\" && args[i + 1]) {\n platforms.push(...(args[++i]!.split(\",\") as Platform[]));\n } else if (arg === \"--tag\" && args[i + 1]) {\n tags = args[++i]!.split(\",\");\n } else if (arg === \"--grep\" && args[i + 1]) {\n grep = args[++i];\n } else if (arg === \"--reporter\" && args[i + 1]) {\n reporter = args[++i]!;\n } else if (arg === \"--config\" && args[i + 1]) {\n configPath = args[++i];\n } else if (arg === \"--retries\" && args[i + 1]) {\n retries = parseInt(args[++i]!, 10);\n } else if (arg === \"--device\" && args[i + 1]) {\n device = args[++i];\n } else if (arg === \"--driver\" && args[i + 1]) {\n driver = args[++i] as \"local\" | \"appium\";\n } else if (arg === \"--appium-url\" && args[i + 1]) {\n appiumUrl = args[++i];\n } else if (arg === \"--caps\" && args[i + 1]) {\n capsPath = args[++i];\n } else if (arg === \"--caps-json\" && args[i + 1]) {\n capsJson = args[++i];\n } else if (arg === \"--no-provider-reporting\") {\n noProviderReporting = true;\n } else if (arg === \"--validate-config\") {\n validateConfigOnly = true;\n } else if (arg === \"--shard\" && args[i + 1]) {\n const [currentText, totalText] = args[++i]!.split(\"/\");\n const current = Number(currentText);\n const total = Number(totalText);\n if (\n !Number.isInteger(current) ||\n !Number.isInteger(total) ||\n current < 1 ||\n total < 1 ||\n current > total\n ) {\n console.log(\n \"Invalid --shard format. Use --shard <current>/<total> with 1 <= current <= total.\",\n );\n process.exit(1);\n }\n shard = { current, total };\n } else if (arg === \"--bail\" && args[i + 1]) {\n bail = Number.parseInt(args[++i]!, 10);\n if (!Number.isInteger(bail) || bail < 1) {\n console.log(\"Invalid --bail value. Use --bail <n> with n >= 1.\");\n process.exit(1);\n }\n } else if (arg === \"--debug-on-failure\") {\n debugOnFailure = true;\n } else if (arg === \"--quiet\" || arg === \"-q\") {\n quiet = true;\n } else if (!arg.startsWith(\"--\")) {\n flowPath = arg;\n }\n }\n\n const { runTestCommand } = await import(\"./test-command.js\");\n const success = await runTestCommand({\n platforms,\n tags,\n grep,\n reporter,\n configPath,\n flowPath,\n retries,\n device,\n driver,\n appiumUrl,\n capsPath,\n capsJson,\n noProviderReporting,\n validateConfigOnly,\n shard,\n bail,\n debugOnFailure,\n quiet,\n });\n process.exit(success ? 0 : 1);\n} else if (command === \"hierarchy\" || command === \"selectors\") {\n let platform: Platform = \"web\";\n let pretty = false;\n let configPath: string | undefined;\n for (let i = 1; i < args.length; i++) {\n if (args[i] === \"--platform\" && args[i + 1]) platform = args[++i] as Platform;\n if (args[i] === \"--pretty\") pretty = true;\n if (args[i] === \"--config\" && args[i + 1]) configPath = args[++i];\n }\n // Load config for baseUrl/packageName/bundleId\n let config: Record<string, any> = {};\n try {\n const { loadConfig } = await import(\"./config-loader.js\");\n config = (await loadConfig({ configPath, allowMissing: true })).config as Record<string, any>;\n } catch (error) {\n console.log(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n const { connect } = await import(\"../agent/session.js\");\n const session = await connect({\n platform,\n baseUrl: config.apps?.web?.url,\n browser: config.execution?.web?.browser,\n headless: config.execution?.web?.headless,\n storageState: config.execution?.web?.storageState,\n packageName: config.apps?.android?.packageName,\n bundleId: config.apps?.ios?.bundleId,\n });\n if (command === \"hierarchy\") {\n const root = await session.hierarchy();\n console.log(pretty ? JSON.stringify(root, null, 2) : JSON.stringify(root));\n } else {\n const elements = await session.selectors();\n console.log(JSON.stringify(elements, null, 2));\n }\n await session.disconnect();\n} else if (command === \"validate\") {\n const path = args[1] ?? \"./flows\";\n const { validateProject } = await import(\"../core/validator.js\");\n const errors = await validateProject(path);\n if (errors.length === 0) {\n const { discoverFlows } = await import(\"../core/runner.js\");\n const paths = await discoverFlows(path);\n console.log(`✓ ${paths.length} flow(s) valid`);\n } else {\n for (const e of errors) console.log(`✗ ${e.file}: ${e.error}`);\n process.exit(1);\n }\n} else if (command === \"validate-config\") {\n let configPath: string | undefined;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i]!;\n if (arg === \"--config\" && args[i + 1]) {\n configPath = args[++i];\n } else if (!arg.startsWith(\"--\")) {\n configPath = arg;\n }\n }\n const { loadConfig } = await import(\"./config-loader.js\");\n try {\n const result = await loadConfig({ configPath });\n console.log(`✓ Config valid (${result.configPath})`);\n } catch (error) {\n console.log(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n} else if (command === \"studio\") {\n let port = 4400;\n let open = true;\n let configPath: string | undefined;\n for (let i = 1; i < args.length; i++) {\n if (args[i] === \"--port\" && args[i + 1]) port = Number(args[++i]);\n if (args[i] === \"--no-open\") open = false;\n if (args[i] === \"--config\" && args[i + 1]) configPath = args[++i];\n }\n let config: Record<string, any> = {};\n try {\n const { loadConfig } = await import(\"./config-loader.js\");\n config = (await loadConfig({ configPath, allowMissing: true })).config as Record<string, any>;\n } catch (error) {\n console.log(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n const { runStudioCommand } = await import(\"./studio-command.js\");\n await runStudioCommand({ port, open, config: config as any });\n} else if (command === \"init\") {\n const force = args.includes(\"--force\");\n const { runInitCommand } = await import(\"./init-command.js\");\n await runInitCommand({ force });\n} else if (command === \"devices\") {\n const { discoverDevices } = await import(\"../device/discover.js\");\n const devices = discoverDevices([\"web\", \"android\", \"ios\"]);\n if (devices.length === 0) {\n console.log(\"No devices found.\");\n } else {\n for (const d of devices) {\n console.log(` ${d.platform.padEnd(8)} ${d.name.padEnd(30)} ${d.type.padEnd(10)} ${d.state}`);\n }\n }\n} else if (command === \"version\" || args.includes(\"--version\") || args.includes(\"-v\")) {\n console.log(\"spana v0.0.1\");\n} else {\n console.log(\"spana — TypeScript-native E2E testing for React Native + Web\");\n console.log(\"\");\n console.log(\"Commands:\");\n console.log(\" spana test [path] Run test flows\");\n console.log(\" spana hierarchy --platform <p> Dump element hierarchy as JSON\");\n console.log(\" spana selectors --platform <p> List actionable elements with suggested selectors\");\n console.log(\" spana validate [path] Validate flow files without device connection\");\n console.log(\" spana validate-config [path] Validate spana.config.ts without running flows\");\n console.log(\" spana studio Launch Spana Studio UI\");\n console.log(\" spana init Initialize a new spana project\");\n console.log(\" spana devices List connected devices across platforms\");\n console.log(\" spana version Show version\");\n console.log(\"\");\n console.log(\"Options:\");\n console.log(\" --platform web,android,ios Platforms to test (default: spana.config.ts or web)\");\n console.log(\" --tag smoke,auth Filter by tags\");\n console.log(\" --grep login Filter by name pattern\");\n console.log(\n \" --reporter console|json|junit Reporter format (default: spana.config.ts or console)\",\n );\n console.log(\" --retries <n> Retry failed flows n times (flake detection)\");\n console.log(\" --shard <current>/<total> Distribute flows across CI jobs\");\n console.log(\" --bail <n> Abort after N failures\");\n console.log(\" --debug-on-failure Open an interactive REPL on the first failed flow\");\n console.log(\" --quiet, -q Only show failures and final summary\");\n console.log(\" --device <id> Target a specific device by ID\");\n console.log(\" --validate-config Validate config and exit\");\n console.log(\" --config path Config file path\");\n console.log(\" --pretty Pretty-print JSON output (hierarchy command)\");\n console.log(\" --port <number> Studio port (default: 4400)\");\n console.log(\" --no-open Don't open browser (studio command)\");\n console.log(\" --force Overwrite existing files (init command)\");\n}\n"],"mappings":";AAEA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AAEtB,IAAI,YAAY,QAAQ;AACtB,QAAM,YAAwB,CAAC;AAC/B,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ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,OAAO;AACL,UAAQ,IAAI,mEAA8D;AAC1E,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,WAAW;AACvB,UAAQ,IAAI,iDAAiD;AAC7D,UAAQ,IAAI,iEAAiE;AAC7E,UAAQ,IAAI,oFAAoF;AAChG,UAAQ,IAAI,gFAAgF;AAC5F,UAAQ,IAAI,iFAAiF;AAC7F,UAAQ,IAAI,yDAAyD;AACrE,UAAQ,IAAI,iEAAiE;AAC7E,UAAQ,IAAI,0EAA0E;AACtF,UAAQ,IAAI,+CAA+C;AAC3D,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,UAAU;AACtB,UAAQ,IAAI,mFAAmF;AAC/F,UAAQ,IAAI,6CAA6C;AACzD,UAAQ,IAAI,qDAAqD;AACjE,UAAQ;AAAA,IACN;AAAA,EACF;AACA,UAAQ,IAAI,2EAA2E;AACvF,UAAQ,IAAI,6DAA6D;AACzE,UAAQ,IAAI,qDAAqD;AACjE,UAAQ,IAAI,gFAAgF;AAC5F,UAAQ,IAAI,mEAAmE;AAC/E,UAAQ,IAAI,6DAA6D;AACzE,UAAQ,IAAI,uDAAuD;AACnE,UAAQ,IAAI,+CAA+C;AAC3D,UAAQ,IAAI,2EAA2E;AACvF,UAAQ,IAAI,0DAA0D;AACtE,UAAQ,IAAI,kEAAkE;AAC9E,UAAQ,IAAI,sEAAsE;AACpF;","names":[]}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWorldFactory,
|
|
3
|
+
globalRegistry
|
|
4
|
+
} from "./chunk-3FSZNKEF.js";
|
|
5
|
+
import "./chunk-DGUM43GV.js";
|
|
6
|
+
|
|
7
|
+
// src/gherkin/compiler.ts
|
|
8
|
+
import { Parser, AstBuilder, GherkinClassicTokenMatcher } from "@cucumber/gherkin";
|
|
9
|
+
import { IdGenerator } from "@cucumber/messages";
|
|
10
|
+
|
|
11
|
+
// src/gherkin/matcher.ts
|
|
12
|
+
import {
|
|
13
|
+
CucumberExpression,
|
|
14
|
+
RegularExpression,
|
|
15
|
+
ParameterTypeRegistry
|
|
16
|
+
} from "@cucumber/cucumber-expressions";
|
|
17
|
+
function createStepMatcher(steps) {
|
|
18
|
+
const parameterTypeRegistry = new ParameterTypeRegistry();
|
|
19
|
+
const compiled = steps.map((handler) => {
|
|
20
|
+
const expression = handler.pattern instanceof RegExp ? new RegularExpression(handler.pattern, parameterTypeRegistry) : new CucumberExpression(handler.pattern, parameterTypeRegistry);
|
|
21
|
+
return { handler, expression };
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
match(text) {
|
|
25
|
+
const matches = [];
|
|
26
|
+
for (const { handler, expression } of compiled) {
|
|
27
|
+
const result = expression.match(text);
|
|
28
|
+
if (result) {
|
|
29
|
+
matches.push({
|
|
30
|
+
handler,
|
|
31
|
+
args: result.map((arg) => arg.getValue(null))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (matches.length === 0) return void 0;
|
|
36
|
+
if (matches.length > 1) {
|
|
37
|
+
const patterns = matches.map((m) => ` "${m.handler.pattern}"`).join("\n");
|
|
38
|
+
throw new Error(`Ambiguous step definition for "${text}". Matches:
|
|
39
|
+
${patterns}`);
|
|
40
|
+
}
|
|
41
|
+
return matches[0];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/gherkin/compiler.ts
|
|
47
|
+
var PLATFORM_TAGS = {
|
|
48
|
+
"@web": "web",
|
|
49
|
+
"@android": "android",
|
|
50
|
+
"@ios": "ios"
|
|
51
|
+
};
|
|
52
|
+
function compileFeature(source, filePath) {
|
|
53
|
+
const parser = new Parser(new AstBuilder(IdGenerator.uuid()), new GherkinClassicTokenMatcher());
|
|
54
|
+
const document = parser.parse(source);
|
|
55
|
+
const feature = document.feature;
|
|
56
|
+
if (!feature) return [];
|
|
57
|
+
const featureTags = feature.tags.map((t) => t.name);
|
|
58
|
+
const flows = [];
|
|
59
|
+
let backgroundSteps = [];
|
|
60
|
+
for (const child of feature.children) {
|
|
61
|
+
if (child.background) {
|
|
62
|
+
backgroundSteps = child.background.steps;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const child of feature.children) {
|
|
66
|
+
if (!child.scenario) continue;
|
|
67
|
+
const scenario = child.scenario;
|
|
68
|
+
if (scenario.examples.length > 0) {
|
|
69
|
+
for (const example of scenario.examples) {
|
|
70
|
+
if (!example.tableHeader || !example.tableBody) continue;
|
|
71
|
+
const headers = example.tableHeader.cells.map((c) => c.value);
|
|
72
|
+
const exampleTags = example.tags.map((t) => t.name);
|
|
73
|
+
for (const row of example.tableBody) {
|
|
74
|
+
const values = row.cells.map((c) => c.value);
|
|
75
|
+
const replacements = {};
|
|
76
|
+
for (let i = 0; i < headers.length; i++) {
|
|
77
|
+
replacements[headers[i]] = values[i] ?? "";
|
|
78
|
+
}
|
|
79
|
+
const expandedName = replaceOutlinePlaceholders(scenario.name, replacements);
|
|
80
|
+
const expandedSteps = scenario.steps.map((s) => ({
|
|
81
|
+
...s,
|
|
82
|
+
text: replaceOutlinePlaceholders(s.text, replacements)
|
|
83
|
+
}));
|
|
84
|
+
const allTags = [...featureTags, ...scenario.tags.map((t) => t.name), ...exampleTags];
|
|
85
|
+
flows.push(
|
|
86
|
+
buildFlowDefinition(
|
|
87
|
+
`${feature.name} \u2014 ${expandedName}`,
|
|
88
|
+
allTags,
|
|
89
|
+
backgroundSteps,
|
|
90
|
+
expandedSteps,
|
|
91
|
+
filePath
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
const allTags = [...featureTags, ...scenario.tags.map((t) => t.name)];
|
|
98
|
+
flows.push(
|
|
99
|
+
buildFlowDefinition(
|
|
100
|
+
`${feature.name} \u2014 ${scenario.name}`,
|
|
101
|
+
allTags,
|
|
102
|
+
backgroundSteps,
|
|
103
|
+
scenario.steps,
|
|
104
|
+
filePath
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return flows;
|
|
110
|
+
}
|
|
111
|
+
function buildFlowDefinition(name, tags, backgroundSteps, scenarioSteps, filePath) {
|
|
112
|
+
const { platforms, filteredTags } = extractPlatformTags(tags);
|
|
113
|
+
const config = {
|
|
114
|
+
tags: filteredTags.length > 0 ? filteredTags : void 0,
|
|
115
|
+
platforms: platforms.length > 0 ? platforms : void 0,
|
|
116
|
+
autoLaunch: false
|
|
117
|
+
// Gherkin flows use Background/Given steps to navigate
|
|
118
|
+
};
|
|
119
|
+
const allSteps = [...backgroundSteps, ...scenarioSteps];
|
|
120
|
+
return {
|
|
121
|
+
name,
|
|
122
|
+
config,
|
|
123
|
+
fn: async (flowCtx) => {
|
|
124
|
+
const matcher = createStepMatcher(globalRegistry.getSteps());
|
|
125
|
+
const state = /* @__PURE__ */ new Map();
|
|
126
|
+
const worldFactory = getWorldFactory();
|
|
127
|
+
const world = worldFactory?.instantiate(flowCtx, state);
|
|
128
|
+
const scenarioStepResults = [];
|
|
129
|
+
const beforeHooks = globalRegistry.getHooks("Before");
|
|
130
|
+
const afterHooks = globalRegistry.getHooks("After");
|
|
131
|
+
const stepCtx = {
|
|
132
|
+
...flowCtx,
|
|
133
|
+
state,
|
|
134
|
+
...world
|
|
135
|
+
};
|
|
136
|
+
for (const hook of beforeHooks) {
|
|
137
|
+
if (hook.tagExpression && !tagsMatch(tags, hook.tagExpression)) continue;
|
|
138
|
+
const hookStart = Date.now();
|
|
139
|
+
try {
|
|
140
|
+
await hook.fn(stepCtx);
|
|
141
|
+
scenarioStepResults.push({
|
|
142
|
+
keyword: "Before",
|
|
143
|
+
text: hook.tagExpression ?? "hook",
|
|
144
|
+
status: "passed",
|
|
145
|
+
durationMs: Date.now() - hookStart
|
|
146
|
+
});
|
|
147
|
+
} catch (error) {
|
|
148
|
+
scenarioStepResults.push({
|
|
149
|
+
keyword: "Before",
|
|
150
|
+
text: hook.tagExpression ?? "hook",
|
|
151
|
+
status: "failed",
|
|
152
|
+
durationMs: Date.now() - hookStart,
|
|
153
|
+
error: error instanceof Error ? error.message : String(error)
|
|
154
|
+
});
|
|
155
|
+
await runAfterHooks(afterHooks, stepCtx, tags, scenarioStepResults);
|
|
156
|
+
attachScenarioSteps(flowCtx, scenarioStepResults);
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let failed = false;
|
|
161
|
+
let failError;
|
|
162
|
+
for (const step of allSteps) {
|
|
163
|
+
const keyword = normalizeKeyword(step.keyword);
|
|
164
|
+
const stepStart = Date.now();
|
|
165
|
+
if (failed) {
|
|
166
|
+
scenarioStepResults.push({
|
|
167
|
+
keyword,
|
|
168
|
+
text: step.text,
|
|
169
|
+
status: "skipped",
|
|
170
|
+
durationMs: 0
|
|
171
|
+
});
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const match = matcher.match(step.text);
|
|
175
|
+
if (!match) {
|
|
176
|
+
const error = `Undefined step: "${step.keyword.trim()} ${step.text}"${filePath ? ` in ${filePath}` : ""}`;
|
|
177
|
+
scenarioStepResults.push({
|
|
178
|
+
keyword,
|
|
179
|
+
text: step.text,
|
|
180
|
+
status: "failed",
|
|
181
|
+
durationMs: Date.now() - stepStart,
|
|
182
|
+
error
|
|
183
|
+
});
|
|
184
|
+
failed = true;
|
|
185
|
+
failError = new Error(error);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const args = buildStepArgs(match, step);
|
|
190
|
+
await match.handler.fn(stepCtx, ...args);
|
|
191
|
+
scenarioStepResults.push({
|
|
192
|
+
keyword,
|
|
193
|
+
text: step.text,
|
|
194
|
+
status: "passed",
|
|
195
|
+
durationMs: Date.now() - stepStart
|
|
196
|
+
});
|
|
197
|
+
} catch (error) {
|
|
198
|
+
scenarioStepResults.push({
|
|
199
|
+
keyword,
|
|
200
|
+
text: step.text,
|
|
201
|
+
status: "failed",
|
|
202
|
+
durationMs: Date.now() - stepStart,
|
|
203
|
+
error: error instanceof Error ? error.message : String(error)
|
|
204
|
+
});
|
|
205
|
+
failed = true;
|
|
206
|
+
failError = error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
await runAfterHooks(afterHooks, stepCtx, tags, scenarioStepResults);
|
|
210
|
+
attachScenarioSteps(flowCtx, scenarioStepResults);
|
|
211
|
+
if (failError) throw failError;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
async function runAfterHooks(hooks, stepCtx, tags, results) {
|
|
216
|
+
for (const hook of hooks) {
|
|
217
|
+
if (hook.tagExpression && !tagsMatch(tags, hook.tagExpression)) continue;
|
|
218
|
+
const hookStart = Date.now();
|
|
219
|
+
try {
|
|
220
|
+
await hook.fn(stepCtx);
|
|
221
|
+
results.push({
|
|
222
|
+
keyword: "After",
|
|
223
|
+
text: hook.tagExpression ?? "hook",
|
|
224
|
+
status: "passed",
|
|
225
|
+
durationMs: Date.now() - hookStart
|
|
226
|
+
});
|
|
227
|
+
} catch (error) {
|
|
228
|
+
results.push({
|
|
229
|
+
keyword: "After",
|
|
230
|
+
text: hook.tagExpression ?? "hook",
|
|
231
|
+
status: "failed",
|
|
232
|
+
durationMs: Date.now() - hookStart,
|
|
233
|
+
error: error instanceof Error ? error.message : String(error)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function attachScenarioSteps(flowCtx, scenarioSteps) {
|
|
239
|
+
flowCtx.__scenarioSteps = scenarioSteps;
|
|
240
|
+
}
|
|
241
|
+
function extractPlatformTags(tags) {
|
|
242
|
+
const platforms = [];
|
|
243
|
+
const filteredTags = [];
|
|
244
|
+
for (const tag of tags) {
|
|
245
|
+
const platform = PLATFORM_TAGS[tag.toLowerCase()];
|
|
246
|
+
if (platform) {
|
|
247
|
+
platforms.push(platform);
|
|
248
|
+
} else {
|
|
249
|
+
filteredTags.push(tag);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return { platforms, filteredTags };
|
|
253
|
+
}
|
|
254
|
+
function normalizeKeyword(keyword) {
|
|
255
|
+
const trimmed = keyword.trim();
|
|
256
|
+
switch (trimmed) {
|
|
257
|
+
case "Given":
|
|
258
|
+
return "Given";
|
|
259
|
+
case "When":
|
|
260
|
+
return "When";
|
|
261
|
+
case "Then":
|
|
262
|
+
return "Then";
|
|
263
|
+
case "And":
|
|
264
|
+
return "And";
|
|
265
|
+
case "But":
|
|
266
|
+
return "But";
|
|
267
|
+
case "*":
|
|
268
|
+
return "And";
|
|
269
|
+
default:
|
|
270
|
+
return "Given";
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function replaceOutlinePlaceholders(text, replacements) {
|
|
274
|
+
return text.replace(/<([^>]+)>/g, (_, key) => replacements[key] ?? `<${key}>`);
|
|
275
|
+
}
|
|
276
|
+
function buildStepArgs(match, step) {
|
|
277
|
+
const args = [...match.args];
|
|
278
|
+
if (step.dataTable) {
|
|
279
|
+
const rows = step.dataTable.rows.map((r) => r.cells.map((c) => c.value));
|
|
280
|
+
args.push(rows);
|
|
281
|
+
}
|
|
282
|
+
if (step.docString) {
|
|
283
|
+
args.push(step.docString.content);
|
|
284
|
+
}
|
|
285
|
+
return args;
|
|
286
|
+
}
|
|
287
|
+
function tagsMatch(scenarioTags, expression) {
|
|
288
|
+
const parts = expression.split(/\s+/);
|
|
289
|
+
let result = true;
|
|
290
|
+
let negate = false;
|
|
291
|
+
for (const part of parts) {
|
|
292
|
+
if (part === "and") continue;
|
|
293
|
+
if (part === "not") {
|
|
294
|
+
negate = true;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (part === "or") {
|
|
298
|
+
if (result) return true;
|
|
299
|
+
result = true;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const hasTag = scenarioTags.includes(part);
|
|
303
|
+
const matches = negate ? !hasTag : hasTag;
|
|
304
|
+
result = result && matches;
|
|
305
|
+
negate = false;
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
export {
|
|
310
|
+
compileFeature
|
|
311
|
+
};
|
|
312
|
+
//# sourceMappingURL=compiler-G75RIIYS.js.map
|