spana-test 0.2.0 → 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 +47 -12
- package/dist/accessibility-audit-RS3VIWRT.js +140 -0
- package/dist/accessibility-audit-RS3VIWRT.js.map +1 -0
- package/dist/agent/index.d.ts +8 -26
- package/dist/agent/index.js +12 -15
- package/dist/{allure-PTTVORQ6.js → allure-RNMEYTXS.js} +42 -2
- package/dist/allure-RNMEYTXS.js.map +1 -0
- package/dist/{android-PAPJJWVN.js → android-GFW6OXPQ.js} +16 -2
- package/dist/appium-server-66GVUL24.js +119 -0
- package/dist/appium-server-66GVUL24.js.map +1 -0
- package/dist/baseline-manager-5TIUCNP5.js +38 -0
- package/dist/baseline-manager-5TIUCNP5.js.map +1 -0
- package/dist/chunk-3J4NG7JU.js +80 -0
- package/dist/chunk-3J4NG7JU.js.map +1 -0
- package/dist/{chunk-MRH7SK52.js → chunk-3TRMQCUT.js} +3 -2
- package/dist/chunk-3TRMQCUT.js.map +1 -0
- package/dist/chunk-5245YBLL.js +127 -0
- package/dist/chunk-5245YBLL.js.map +1 -0
- package/dist/{chunk-L7MFJF46.js → chunk-7VOWF42B.js} +29 -5
- package/dist/chunk-7VOWF42B.js.map +1 -0
- package/dist/{chunk-GZK22EIE.js → chunk-EWIR2GVV.js} +54 -1
- package/dist/chunk-EWIR2GVV.js.map +1 -0
- package/dist/{chunk-P7JQRLP4.js → chunk-FJAJ4YNC.js} +14 -2
- package/dist/chunk-FJAJ4YNC.js.map +1 -0
- package/dist/chunk-IHVZKQQW.js +24 -0
- package/dist/chunk-IHVZKQQW.js.map +1 -0
- package/dist/{chunk-S4R4OR7T.js → chunk-KYPLYRKW.js} +67 -72
- package/dist/chunk-KYPLYRKW.js.map +1 -0
- package/dist/{chunk-YBZCOQXJ.js → chunk-LC3QJIHY.js} +196 -67
- package/dist/chunk-LC3QJIHY.js.map +1 -0
- package/dist/{chunk-WQ4GXUUE.js → chunk-MCT4DYDK.js} +353 -84
- package/dist/chunk-MCT4DYDK.js.map +1 -0
- package/dist/chunk-OBCFACUW.js +28 -0
- package/dist/chunk-OBCFACUW.js.map +1 -0
- package/dist/{chunk-AEKDFFPJ.js → chunk-PZYZ4O6D.js} +16 -5
- package/dist/chunk-PZYZ4O6D.js.map +1 -0
- package/dist/{chunk-SFBRFB2N.js → chunk-S5JNNDXS.js} +62 -12
- package/dist/chunk-S5JNNDXS.js.map +1 -0
- package/dist/{chunk-VNYF5BHX.js → chunk-X2TJP7LB.js} +1 -3
- package/dist/{chunk-S2XNAKSO.js → chunk-YAV6KBSW.js} +564 -333
- package/dist/chunk-YAV6KBSW.js.map +1 -0
- package/dist/{chunk-3YR4GUGE.js → chunk-YGHDMA6D.js} +65 -70
- package/dist/chunk-YGHDMA6D.js.map +1 -0
- package/dist/cli.js +40 -25
- package/dist/cli.js.map +1 -1
- package/dist/{compiler-74VGKZO6.js → compiler-X6WTFMYF.js} +15 -7
- package/dist/compiler-X6WTFMYF.js.map +1 -0
- package/dist/config-loader-QM72GKEL.js +9 -0
- package/dist/{console-XWKUTP3D.js → console-7UW7VROK.js} +71 -1
- package/dist/console-7UW7VROK.js.map +1 -0
- package/dist/{discover-KZKXHZZA.js → discover-CAQY6EG6.js} +5 -4
- package/dist/doctor-command-YGQPO7GH.js +71 -0
- package/dist/doctor-command-YGQPO7GH.js.map +1 -0
- package/dist/flow-thjUxXXx.d.ts +168 -0
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-GE6Q4DCG.js → html-F3X3XPSX.js} +78 -7
- package/dist/html-F3X3XPSX.js.map +1 -0
- package/dist/index.d.ts +4 -8
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{init-command-GVMRXIMY.js → init-command-U66XCM66.js} +19 -34
- package/dist/init-command-U66XCM66.js.map +1 -0
- package/dist/init-flow-command-PR7J5FBM.js +37 -0
- package/dist/init-flow-command-PR7J5FBM.js.map +1 -0
- package/dist/{installer-YZJ4DV3F.js → installer-PVBSX7UC.js} +3 -4
- package/dist/{ios-ZW6XVNLG.js → ios-JPK43TFZ.js} +11 -4
- package/dist/json-JMRPUVY2.js +20 -0
- package/dist/json-JMRPUVY2.js.map +1 -0
- package/dist/machine-6H25TRTU.js +16 -0
- package/dist/{provider-A57C3MU6.js → provider-YIPU5K42.js} +2 -2
- package/dist/{runner-UXNHVVGG.js → runner-6HK62Q7B.js} +2 -2
- package/dist/screenshot-compare-JFHH2WR4.js +75 -0
- package/dist/screenshot-compare-JFHH2WR4.js.map +1 -0
- package/dist/{server-W7OA3DDN.js → server-PZBRGU7P.js} +362 -55
- package/dist/server-PZBRGU7P.js.map +1 -0
- package/dist/session-2MZVGYAC.js +17 -0
- package/dist/{coordinator-BbUjvvnX.d.ts → storybook-pBOPe_1D.d.ts} +101 -33
- package/dist/{studio-command-6VHTHDUK.js → studio-command-YDWQOMRX.js} +2 -2
- package/dist/{test-command-AHMOZLV4.js → test-command-B2VLWGDK.js} +945 -565
- package/dist/test-command-B2VLWGDK.js.map +1 -0
- package/dist/{validator-35624P7S.js → validator-HZ2A3NEI.js} +3 -6
- package/dist/validator-HZ2A3NEI.js.map +1 -0
- package/package.json +6 -1
- package/studio-dist/assets/index-C-Io44gy.js +193 -0
- package/studio-dist/assets/index-DfM9lK4p.css +1 -0
- package/studio-dist/index.html +2 -2
- package/dist/allure-PTTVORQ6.js.map +0 -1
- package/dist/chunk-3YR4GUGE.js.map +0 -1
- package/dist/chunk-AEKDFFPJ.js.map +0 -1
- package/dist/chunk-BF37W5EG.js +0 -125
- package/dist/chunk-BF37W5EG.js.map +0 -1
- package/dist/chunk-EXLUY7KT.js +0 -21
- package/dist/chunk-EXLUY7KT.js.map +0 -1
- package/dist/chunk-FNDOEMOL.js +0 -62
- package/dist/chunk-FNDOEMOL.js.map +0 -1
- package/dist/chunk-GZK22EIE.js.map +0 -1
- package/dist/chunk-HWFDXIXR.js +0 -183
- package/dist/chunk-HWFDXIXR.js.map +0 -1
- package/dist/chunk-IJIASIX5.js +0 -314
- package/dist/chunk-IJIASIX5.js.map +0 -1
- package/dist/chunk-L7MFJF46.js.map +0 -1
- package/dist/chunk-MRH7SK52.js.map +0 -1
- package/dist/chunk-P7JQRLP4.js.map +0 -1
- package/dist/chunk-S2XNAKSO.js.map +0 -1
- package/dist/chunk-S4R4OR7T.js.map +0 -1
- package/dist/chunk-SFBRFB2N.js.map +0 -1
- package/dist/chunk-WBU34APM.js +0 -38
- package/dist/chunk-WBU34APM.js.map +0 -1
- package/dist/chunk-WQ4GXUUE.js.map +0 -1
- package/dist/chunk-YBZCOQXJ.js.map +0 -1
- package/dist/compiler-74VGKZO6.js.map +0 -1
- package/dist/config-loader-BJJ3IJJ7.js +0 -9
- package/dist/console-XWKUTP3D.js.map +0 -1
- package/dist/doctor-command-T2UX5RV5.js +0 -732
- package/dist/doctor-command-T2UX5RV5.js.map +0 -1
- package/dist/flow-BUC9Mf8W.d.ts +0 -128
- package/dist/html-GE6Q4DCG.js.map +0 -1
- package/dist/init-command-GVMRXIMY.js.map +0 -1
- package/dist/init-flow-command-R76AXF4Z.js +0 -34
- package/dist/init-flow-command-R76AXF4Z.js.map +0 -1
- package/dist/json-KS67BZYU.js +0 -39
- package/dist/json-KS67BZYU.js.map +0 -1
- package/dist/server-W7OA3DDN.js.map +0 -1
- package/dist/session-TMNOKYLG.js +0 -17
- package/dist/test-command-AHMOZLV4.js.map +0 -1
- package/studio-dist/assets/index-DC6DIXfl.js +0 -188
- package/studio-dist/assets/index-DDKsnBwD.css +0 -1
- /package/dist/{android-PAPJJWVN.js.map → android-GFW6OXPQ.js.map} +0 -0
- /package/dist/{chunk-VNYF5BHX.js.map → chunk-X2TJP7LB.js.map} +0 -0
- /package/dist/{config-loader-BJJ3IJJ7.js.map → config-loader-QM72GKEL.js.map} +0 -0
- /package/dist/{discover-KZKXHZZA.js.map → discover-CAQY6EG6.js.map} +0 -0
- /package/dist/{installer-YZJ4DV3F.js.map → installer-PVBSX7UC.js.map} +0 -0
- /package/dist/{ios-ZW6XVNLG.js.map → ios-JPK43TFZ.js.map} +0 -0
- /package/dist/{provider-A57C3MU6.js.map → machine-6H25TRTU.js.map} +0 -0
- /package/dist/{runner-UXNHVVGG.js.map → provider-YIPU5K42.js.map} +0 -0
- /package/dist/{session-TMNOKYLG.js.map → runner-6HK62Q7B.js.map} +0 -0
- /package/dist/{validator-35624P7S.js.map → session-2MZVGYAC.js.map} +0 -0
- /package/dist/{studio-command-6VHTHDUK.js.map → studio-command-YDWQOMRX.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/appium-server.ts"],"sourcesContent":["/**\n * Opt-in local Appium server lifecycle management.\n *\n * When `execution.appium.autoStart` is true (or `--appium-auto-start` is\n * passed), spana spawns a local `appium` subprocess, waits for it to\n * become ready, and returns a URL + cleanup function. The server is torn\n * down on process exit (including Ctrl-C and test failures) via the\n * runCleanups mechanism in test-command.ts.\n *\n * This is for dev iteration on Appium driver bugs without burning cloud\n * minutes. Never starts implicitly — opt-in only.\n */\n\nimport { spawn, type ChildProcess } from \"node:child_process\";\nimport { createServer } from \"node:net\";\n\nexport interface AutoStartedAppium {\n url: string;\n stop: () => Promise<void>;\n}\n\nexport interface AutoStartOptions {\n /** Max ms to wait for the server to become ready. Default: 30000 */\n readyTimeout?: number;\n /** Executable name. Default: \"appium\" */\n binary?: string;\n /** Extra CLI args to pass through to appium. */\n extraArgs?: readonly string[];\n /** Optional logger for server stdout/stderr (default: noop). */\n log?: (line: string) => void;\n}\n\nasync function findFreePort(): Promise<number> {\n return new Promise((resolve, reject) => {\n const server = createServer();\n server.unref();\n server.on(\"error\", reject);\n server.listen(0, () => {\n const address = server.address();\n if (address && typeof address === \"object\") {\n const port = address.port;\n server.close(() => resolve(port));\n } else {\n server.close();\n reject(new Error(\"Failed to allocate free port for Appium\"));\n }\n });\n });\n}\n\n/**\n * Spawns a local Appium server on a free port and waits for it to be ready.\n *\n * @throws if the `appium` binary is not found, or if the server doesn't\n * become ready within the timeout.\n */\nexport async function startLocalAppium(opts: AutoStartOptions = {}): Promise<AutoStartedAppium> {\n const binary = opts.binary ?? \"appium\";\n const readyTimeout = opts.readyTimeout ?? 30_000;\n const log = opts.log ?? (() => {});\n\n const port = await findFreePort();\n const url = `http://127.0.0.1:${port}`;\n\n log(`[appium] starting on ${url}`);\n\n let child: ChildProcess;\n try {\n child = spawn(binary, [\"--port\", String(port), \"--base-path\", \"/\", ...(opts.extraArgs ?? [])], {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n // Detach so we can kill the whole process group on teardown.\n detached: false,\n });\n } catch (e) {\n throw new Error(\n `Failed to spawn \\`${binary}\\`: ${e instanceof Error ? e.message : String(e)}. ` +\n `Install Appium globally (npm i -g appium) and its drivers, or point --appium-url at an existing server.`,\n { cause: e },\n );\n }\n\n child.stdout?.setEncoding(\"utf-8\");\n child.stderr?.setEncoding(\"utf-8\");\n child.stdout?.on(\"data\", (chunk: string) => {\n for (const line of chunk.split(/\\r?\\n/)) if (line) log(`[appium] ${line}`);\n });\n child.stderr?.on(\"data\", (chunk: string) => {\n for (const line of chunk.split(/\\r?\\n/)) if (line) log(`[appium] ${line}`);\n });\n\n // Fail fast if the child exits before we see readiness.\n let exitError: Error | null = null;\n child.once(\"exit\", (code, signal) => {\n if (code !== 0 && code !== null) {\n exitError = new Error(`Appium server exited early with code ${code}`);\n } else if (signal) {\n exitError = new Error(`Appium server exited early with signal ${signal}`);\n }\n });\n\n child.once(\"error\", (err) => {\n exitError = err;\n });\n\n try {\n const deadline = Date.now() + readyTimeout;\n while (Date.now() < deadline) {\n if (exitError) throw exitError;\n try {\n const res = await fetch(`${url}/status`, {\n signal: AbortSignal.timeout(500),\n });\n if (res.ok) {\n const body = (await res.json()) as { value?: { ready?: boolean } };\n if (body.value?.ready !== false) {\n log(`[appium] ready on ${url}`);\n break;\n }\n }\n } catch {\n /* server not up yet, keep polling */\n }\n await new Promise((r) => setTimeout(r, 200));\n }\n if (exitError) throw exitError;\n if (Date.now() >= deadline) {\n throw new Error(`Local Appium server did not become ready`);\n }\n } catch (e) {\n // Clean up the child before propagating.\n try {\n child.kill(\"SIGTERM\");\n } catch {\n /* ignore */\n }\n if (e instanceof Error && /did not become ready/i.test(e.message)) {\n throw new Error(\n `Local Appium server at ${url} did not become ready within ${readyTimeout}ms. ` +\n `Check that \\`${binary}\\` is installed and that required drivers (xcuitest, uiautomator2) are installed.`,\n { cause: e },\n );\n }\n throw e;\n }\n\n let stopped = false;\n const stop = async (): Promise<void> => {\n if (stopped) return;\n stopped = true;\n log(`[appium] stopping ${url}`);\n child.kill(\"SIGTERM\");\n // Wait up to 5s for graceful shutdown, then SIGKILL.\n const killDeadline = Date.now() + 5_000;\n while (child.exitCode === null && child.signalCode === null && Date.now() < killDeadline) {\n await new Promise((r) => setTimeout(r, 100));\n }\n if (child.exitCode === null && child.signalCode === null) {\n log(`[appium] forcing kill`);\n child.kill(\"SIGKILL\");\n }\n };\n\n return { url, stop };\n}\n"],"mappings":";;;AAaA,SAAS,aAAgC;AACzC,SAAS,oBAAoB;AAkB7B,eAAe,eAAgC;AAC7C,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,aAAa;AAC5B,WAAO,MAAM;AACb,WAAO,GAAG,SAAS,MAAM;AACzB,WAAO,OAAO,GAAG,MAAM;AACrB,YAAM,UAAU,OAAO,QAAQ;AAC/B,UAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,cAAM,OAAO,QAAQ;AACrB,eAAO,MAAM,MAAM,QAAQ,IAAI,CAAC;AAAA,MAClC,OAAO;AACL,eAAO,MAAM;AACb,eAAO,IAAI,MAAM,yCAAyC,CAAC;AAAA,MAC7D;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AAQA,eAAsB,iBAAiB,OAAyB,CAAC,GAA+B;AAC9F,QAAM,SAAS,KAAK,UAAU;AAC9B,QAAM,eAAe,KAAK,gBAAgB;A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C3B,YAAM,KAAK,SAAS;AAAA,IACtB;AAAA,EACF;AAEA,SAAO,EAAE,KAAK,KAAK;AACrB;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "./chunk-DGUM43GV.js";
|
|
2
|
+
|
|
3
|
+
// src/core/baseline-manager.ts
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
5
|
+
import { dirname, join } from "path";
|
|
6
|
+
function toSafeName(flowName) {
|
|
7
|
+
return flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
|
|
8
|
+
}
|
|
9
|
+
function resolveBaselinePath(flowFilePath, flowName, platform, screenshotName, baselinesDir) {
|
|
10
|
+
const safeName = toSafeName(flowName);
|
|
11
|
+
if (baselinesDir) {
|
|
12
|
+
return join(baselinesDir, `${safeName}-${platform}`, `${screenshotName}.png`);
|
|
13
|
+
}
|
|
14
|
+
return join(
|
|
15
|
+
dirname(flowFilePath),
|
|
16
|
+
"__baselines__",
|
|
17
|
+
`${safeName}-${platform}`,
|
|
18
|
+
`${screenshotName}.png`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function baselineExists(baselinePath) {
|
|
22
|
+
return existsSync(baselinePath);
|
|
23
|
+
}
|
|
24
|
+
function readBaseline(baselinePath) {
|
|
25
|
+
if (!existsSync(baselinePath)) return null;
|
|
26
|
+
return readFileSync(baselinePath);
|
|
27
|
+
}
|
|
28
|
+
function writeBaseline(baselinePath, data) {
|
|
29
|
+
mkdirSync(dirname(baselinePath), { recursive: true });
|
|
30
|
+
writeFileSync(baselinePath, data);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
baselineExists,
|
|
34
|
+
readBaseline,
|
|
35
|
+
resolveBaselinePath,
|
|
36
|
+
writeBaseline
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=baseline-manager-5TIUCNP5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/baseline-manager.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nfunction toSafeName(flowName: string): string {\n return flowName\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/g, \"-\")\n .replaceAll(/^-|-$/g, \"\");\n}\n\n/**\n * Resolves the path for a baseline screenshot.\n *\n * Path: dirname(flowFilePath)/__baselines__/{safeName}-{platform}/{screenshotName}.png\n */\nexport function resolveBaselinePath(\n flowFilePath: string,\n flowName: string,\n platform: string,\n screenshotName: string,\n baselinesDir?: string,\n): string {\n const safeName = toSafeName(flowName);\n if (baselinesDir) {\n return join(baselinesDir, `${safeName}-${platform}`, `${screenshotName}.png`);\n }\n return join(\n dirname(flowFilePath),\n \"__baselines__\",\n `${safeName}-${platform}`,\n `${screenshotName}.png`,\n );\n}\n\n/** Returns true if the baseline file exists on disk. */\nexport function baselineExists(baselinePath: string): boolean {\n return existsSync(baselinePath);\n}\n\n/**\n * Reads a baseline image from disk.\n * Returns null if the file does not exist.\n */\nexport function readBaseline(baselinePath: string): Buffer | null {\n if (!existsSync(baselinePath)) return null;\n return readFileSync(baselinePath);\n}\n\n/**\n * Writes a baseline image to disk, creating parent directories as needed.\n */\nexport function writeBaseline(baselinePath: string, data: Buffer | Uint8Array): void {\n mkdirSync(dirname(baselinePath), { recursive: true });\n writeFileSync(baselinePath, data);\n}\n"],"mappings":";;;AAAA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,SAAS,YAAY;AAE9B,SAAS,WAAW,UAA0B;AAC5C,SAAO,SACJ,YAAY,EACZ,WAAW,eAAe,GAAG,EAC7B,WAAW,UAAU,EAAE;AAC5B;AAOO,SAAS,oBACd,cACA,UACA,UACA,gBACA,cACQ;AACR,QAAM,WAAW,WAAW,QAAQ;AACpC,MAAI,cAAc;AAChB,WAAO,KAAK,cAAc,GAAG,QAAQ,IAAI,QAAQ,IAAI,GAAG,cAAc,MAAM;AAAA,EAC9E;AACA,SAAO;AAAA,IACL,QAAQ,YAAY;AAAA,IACpB;AAAA,IACA,GAAG,QAAQ,IAAI,QAAQ;AAAA,IACvB,GAAG,cAAc;AAAA,EACnB;AACF;AAGO,SAAS,eAAe,cAA+B;AAC5D,SAAO,WAAW,YAAY;AAChC;AAMO,SAAS,aAAa,cAAqC;AAChE,MAAI,CAAC,WAAW,YAAY,EAAG,QAAO;AACtC,SAAO,aAAa,YAAY;AAClC;AAKO,SAAS,cAAc,cAAsB,MAAiC;AACnF,YAAU,QAAQ,YAAY,GAAG,EAAE,WAAW,KAAK,CAAC;AACpD,gBAAc,cAAc,IAAI;AAClC;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/cli/scaffolds.ts
|
|
2
|
+
var INIT_PRESETS = ["local-web", "local-react-native", "browserstack", "saucelabs"];
|
|
3
|
+
var FLOW_STUB_PRESETS = ["blank", "smoke", "auth"];
|
|
4
|
+
function isInitPreset(value) {
|
|
5
|
+
return INIT_PRESETS.includes(value);
|
|
6
|
+
}
|
|
7
|
+
function isFlowStubPreset(value) {
|
|
8
|
+
return FLOW_STUB_PRESETS.includes(value);
|
|
9
|
+
}
|
|
10
|
+
function generateFlowStub(name, opts) {
|
|
11
|
+
const preset = opts.preset ?? "smoke";
|
|
12
|
+
const platforms = opts.platforms && opts.platforms.length > 0 ? opts.platforms : void 0;
|
|
13
|
+
const tags = opts.tags && opts.tags.length > 0 ? opts.tags : ["smoke"];
|
|
14
|
+
const configParts = [];
|
|
15
|
+
configParts.push(`tags: [${tags.map((t) => `"${t}"`).join(", ")}]`);
|
|
16
|
+
if (platforms) {
|
|
17
|
+
configParts.push(`platforms: [${platforms.map((p) => `"${p}"`).join(", ")}]`);
|
|
18
|
+
}
|
|
19
|
+
const configStr = `{ ${configParts.join(", ")} }`;
|
|
20
|
+
if (preset === "blank") {
|
|
21
|
+
return `import { flow } from "spana-test";
|
|
22
|
+
|
|
23
|
+
export default flow(
|
|
24
|
+
"${name}",
|
|
25
|
+
${configStr},
|
|
26
|
+
async ({ app, expect }) => {
|
|
27
|
+
// Write your test flow here.
|
|
28
|
+
// Run "spana selectors --platform web" to discover available selectors.
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
if (preset === "auth") {
|
|
34
|
+
return `import { flow } from "spana-test";
|
|
35
|
+
|
|
36
|
+
export default flow(
|
|
37
|
+
"${name}",
|
|
38
|
+
${configStr},
|
|
39
|
+
async ({ app, expect, platform }) => {
|
|
40
|
+
// Navigate to login screen
|
|
41
|
+
await expect({ testID: "login-email-input" }).toBeVisible();
|
|
42
|
+
|
|
43
|
+
// Enter credentials
|
|
44
|
+
await app.tap({ testID: "login-email-input" });
|
|
45
|
+
await app.inputText("user@example.com");
|
|
46
|
+
await app.dismissKeyboard();
|
|
47
|
+
|
|
48
|
+
await app.tap({ testID: "login-password-input" });
|
|
49
|
+
await app.inputText("password123");
|
|
50
|
+
await app.dismissKeyboard();
|
|
51
|
+
|
|
52
|
+
// Submit
|
|
53
|
+
await app.tap({ testID: "login-submit-button" });
|
|
54
|
+
|
|
55
|
+
// Verify logged in
|
|
56
|
+
await expect({ testID: "home-screen" }).toBeVisible({ timeout: 10_000 });
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
return `import { flow } from "spana-test";
|
|
62
|
+
|
|
63
|
+
export default flow(
|
|
64
|
+
"${name}",
|
|
65
|
+
${configStr},
|
|
66
|
+
async ({ app, expect }) => {
|
|
67
|
+
// Verify the app loads and the main screen is visible.
|
|
68
|
+
// Replace with a selector from your app \u2014 run "spana selectors" to discover them.
|
|
69
|
+
await expect({ testID: "main-screen" }).toBeVisible({ timeout: 10_000 });
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
isInitPreset,
|
|
77
|
+
isFlowStubPreset,
|
|
78
|
+
generateFlowStub
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=chunk-3J4NG7JU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/scaffolds.ts"],"sourcesContent":["const INIT_PRESETS = [\"local-web\", \"local-react-native\", \"browserstack\", \"saucelabs\"] as const;\nconst FLOW_STUB_PRESETS = [\"blank\", \"smoke\", \"auth\"] as const;\n\nexport type InitPreset = (typeof INIT_PRESETS)[number];\nexport type FlowStubPreset = (typeof FLOW_STUB_PRESETS)[number];\n\nexport function isInitPreset(value: string): value is InitPreset {\n return (INIT_PRESETS as readonly string[]).includes(value);\n}\n\nexport function isFlowStubPreset(value: string): value is FlowStubPreset {\n return (FLOW_STUB_PRESETS as readonly string[]).includes(value);\n}\n\nexport function generateFlowStub(\n name: string,\n opts: { platforms?: string[]; tags?: string[]; preset?: FlowStubPreset },\n): string {\n const preset = opts.preset ?? \"smoke\";\n const platforms = opts.platforms && opts.platforms.length > 0 ? opts.platforms : undefined;\n const tags = opts.tags && opts.tags.length > 0 ? opts.tags : [\"smoke\"];\n\n const configParts: string[] = [];\n configParts.push(`tags: [${tags.map((t) => `\"${t}\"`).join(\", \")}]`);\n if (platforms) {\n configParts.push(`platforms: [${platforms.map((p) => `\"${p}\"`).join(\", \")}]`);\n }\n const configStr = `{ ${configParts.join(\", \")} }`;\n\n if (preset === \"blank\") {\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${name}\",\n ${configStr},\n async ({ app, expect }) => {\n // Write your test flow here.\n // Run \"spana selectors --platform web\" to discover available selectors.\n },\n);\n`;\n }\n\n if (preset === \"auth\") {\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${name}\",\n ${configStr},\n async ({ app, expect, platform }) => {\n // Navigate to login screen\n await expect({ testID: \"login-email-input\" }).toBeVisible();\n\n // Enter credentials\n await app.tap({ testID: \"login-email-input\" });\n await app.inputText(\"user@example.com\");\n await app.dismissKeyboard();\n\n await app.tap({ testID: \"login-password-input\" });\n await app.inputText(\"password123\");\n await app.dismissKeyboard();\n\n // Submit\n await app.tap({ testID: \"login-submit-button\" });\n\n // Verify logged in\n await expect({ testID: \"home-screen\" }).toBeVisible({ timeout: 10_000 });\n },\n);\n`;\n }\n\n // Default: \"smoke\"\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${name}\",\n ${configStr},\n async ({ app, expect }) => {\n // Verify the app loads and the main screen is visible.\n // Replace with a selector from your app — run \"spana selectors\" to discover them.\n await expect({ testID: \"main-screen\" }).toBeVisible({ timeout: 10_000 });\n },\n);\n`;\n}\n"],"mappings":";AAAA,IAAM,eAAe,CAAC,aAAa,sBAAsB,gBAAgB,WAAW;AACpF,IAAM,oBAAoB,CAAC,SAAS,SAAS,MAAM;AAK5C,SAAS,aAAa,OAAoC;AAC/D,SAAQ,aAAmC,SAAS,KAAK;AAC3D;AAEO,SAAS,iBAAiB,OAAwC;AACvE,SAAQ,kBAAwC,SAAS,KAAK;AAChE;AAEO,SAAS,iBACd,MACA,MACQ;AACR,QAAM,SAAS,KAAK,UAAU;AAC9B,QAAM,YAAY,KAAK,aAAa,KAAK,UAAU,SAAS,IAAI,KAAK,YAAY;AACjF,QAAM,OAAO,KAAK,QAAQ,KAAK,KAAK,SAAS,IAAI,KAAK,OAAO,CAAC,OAAO;AAErE,QAAM,cAAwB,CAAC;AAC/B,cAAY,KAAK,UAAU,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG;AAClE,MAAI,WAAW;AACb,gBAAY,KAAK,eAAe,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG;AAAA,EAC9E;AACA,QAAM,YAAY,KAAK,YAAY,KAAK,IAAI,CAAC;AAE7C,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA;AAAA;AAAA,KAGN,IAAI;AAAA,IACL,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOX;AAEA,MAAI,WAAW,QAAQ;AACrB,WAAO;AAAA;AAAA;AAAA,KAGN,IAAI;AAAA,IACL,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBX;AAGA,SAAO;AAAA;AAAA;AAAA,KAGJ,IAAI;AAAA,IACL,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQb;","names":[]}
|
|
@@ -14,6 +14,7 @@ async function loadFlowFile(filePath) {
|
|
|
14
14
|
if (mod.settings) {
|
|
15
15
|
Object.assign(flowDef.config, mod.settings);
|
|
16
16
|
}
|
|
17
|
+
flowDef.sourcePath ??= absolutePath;
|
|
17
18
|
return flowDef;
|
|
18
19
|
}
|
|
19
20
|
async function loadTestSource(filePath) {
|
|
@@ -27,7 +28,7 @@ async function loadTestSource(filePath) {
|
|
|
27
28
|
async function loadFeatureFile(filePath) {
|
|
28
29
|
let compileFeature;
|
|
29
30
|
try {
|
|
30
|
-
const mod = await import("./compiler-
|
|
31
|
+
const mod = await import("./compiler-X6WTFMYF.js");
|
|
31
32
|
compileFeature = mod.compileFeature;
|
|
32
33
|
} catch {
|
|
33
34
|
throw new Error(
|
|
@@ -131,4 +132,4 @@ export {
|
|
|
131
132
|
filterFlows,
|
|
132
133
|
applyShard
|
|
133
134
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-3TRMQCUT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/runner.ts"],"sourcesContent":["import { readdir, readFile, stat } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type { FlowDefinition, FlowConfig } from \"../api/flow.js\";\nimport type { Platform } from \"../schemas/selector.js\";\n\nexport interface DiscoverOptions {\n tags?: string[];\n grep?: string;\n platforms?: Platform[];\n /** Glob patterns for step definition files (relative to flowDir). */\n stepFiles?: string[];\n}\n\nexport interface ShardOptions {\n current: number;\n total: number;\n}\n\nexport async function loadFlowFile(filePath: string): Promise<FlowDefinition> {\n const absolutePath = resolve(filePath);\n const mod = await import(absolutePath);\n\n if (!mod.default) {\n throw new Error(`No default export found in ${filePath}`);\n }\n\n const flowDef = mod.default as FlowDefinition;\n if (!flowDef.name || typeof flowDef.fn !== \"function\") {\n throw new Error(`Invalid flow definition in ${filePath}`);\n }\n\n // Merge exported settings if present\n if (mod.settings) {\n Object.assign(flowDef.config, mod.settings as FlowConfig);\n }\n\n flowDef.sourcePath ??= absolutePath;\n return flowDef;\n}\n\n/**\n * Load a test source file and return one or more FlowDefinitions.\n * Handles both native .flow.ts/.test.ts files and .feature files.\n */\nexport async function loadTestSource(filePath: string): Promise<FlowDefinition[]> {\n const absolutePath = resolve(filePath);\n\n if (absolutePath.endsWith(\".feature\")) {\n return loadFeatureFile(absolutePath);\n }\n\n const flow = await loadFlowFile(absolutePath);\n return [flow];\n}\n\nasync function loadFeatureFile(filePath: string): Promise<FlowDefinition[]> {\n let compileFeature: typeof import(\"../gherkin/compiler.js\").compileFeature;\n try {\n const mod = await import(\"../gherkin/compiler.js\");\n compileFeature = mod.compileFeature;\n } catch {\n throw new Error(\n `Cannot load .feature files: install @cucumber/gherkin, @cucumber/messages, and @cucumber/cucumber-expressions as dependencies.`,\n );\n }\n\n const source = await readFile(filePath, \"utf-8\");\n return compileFeature(source, filePath);\n}\n\n/**\n * Load step definition files so their Given/When/Then registrations\n * are available before feature compilation.\n */\nexport async function loadStepFiles(paths: string[]): Promise<void> {\n for (const p of paths) {\n await import(resolve(p));\n }\n}\n\nexport async function discoverFlows(pathOrDir: string): Promise<string[]> {\n const absolute = resolve(pathOrDir);\n const stats = await stat(absolute);\n\n if (!stats.isDirectory()) {\n return [absolute];\n }\n\n const results: string[] = [];\n\n async function walk(dir: string): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n if (entry.isDirectory()) {\n await walk(fullPath);\n } else if (\n entry.name.endsWith(\".flow.ts\") ||\n entry.name.endsWith(\".test.ts\") ||\n entry.name.endsWith(\".feature\")\n ) {\n results.push(fullPath);\n }\n }\n }\n\n await walk(absolute);\n return results.toSorted();\n}\n\n/**\n * Discover step definition files within a directory.\n * Looks for files in steps/ directories or matching *.steps.ts pattern.\n */\nexport async function discoverStepFiles(pathOrDir: string): Promise<string[]> {\n const absolute = resolve(pathOrDir);\n const stats = await stat(absolute).catch(() => null);\n if (!stats?.isDirectory()) return [];\n\n const results: string[] = [];\n\n async function walk(dir: string): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n if (entry.isDirectory()) {\n await walk(fullPath);\n } else if (entry.name.endsWith(\".steps.ts\") || dir.includes(\"/steps\")) {\n if (entry.name.endsWith(\".ts\")) {\n results.push(fullPath);\n }\n }\n }\n }\n\n await walk(absolute);\n return results.toSorted();\n}\n\nexport function filterFlows(flows: FlowDefinition[], opts: DiscoverOptions): FlowDefinition[] {\n return flows.filter((flow) => {\n if (opts.tags && opts.tags.length > 0) {\n const flowTags = flow.config.tags ?? [];\n if (!opts.tags.some((t) => flowTags.includes(t))) return false;\n }\n if (opts.grep) {\n if (!flow.name.toLowerCase().includes(opts.grep.toLowerCase())) return false;\n }\n if (opts.platforms && opts.platforms.length > 0) {\n const flowPlatforms = flow.config.platforms;\n if (flowPlatforms && !opts.platforms.some((p) => flowPlatforms.includes(p))) return false;\n }\n // Evaluate when conditions\n if (flow.config.when) {\n const when = flow.config.when;\n\n if (when.platform) {\n const allowedPlatforms = Array.isArray(when.platform) ? when.platform : [when.platform];\n if (opts.platforms && opts.platforms.length > 0) {\n if (!opts.platforms.some((p) => allowedPlatforms.includes(p))) return false;\n }\n }\n\n if (when.env && !process.env[when.env]) {\n return false;\n }\n }\n return true;\n });\n}\n\nexport function applyShard<T>(items: T[], shard?: ShardOptions): T[] {\n if (!shard || shard.total === 1 || items.length === 0) {\n return items;\n }\n\n const itemsPerShard = Math.max(Math.ceil(items.length / shard.total), 1);\n const start = (shard.current - 1) * itemsPerShard;\n const end =\n shard.current === shard.total ? items.length : Math.min(start + itemsPerShard, items.length);\n\n return items.slice(start, end);\n}\n"],"mappings":";AAAA,SAAS,SAAS,UAAU,YAAY;AACxC,SAAS,MAAM,eAAe;AAiB9B,eAAsB,aAAa,UAA2C;AAC5E,QAAM,eAAe,QAAQ,QAAQ;AACrC,QAAM,MAAM,MAAM,OAAO;AAEzB,MAAI,CAAC,IAAI,SAAS;AAChB,UAAM,IAAI,MAAM,8BAA8B,QAAQ,EAAE;AAAA,EAC1D;AAEA,QAAM,UAAU,IAAI;AACpB,MAAI,CAAC,QAAQ,QAAQ,OAAO,QAAQ,OAAO,YAAY;AACrD,UAAM,IAAI,MAAM,8BAA8B,QAAQ,EAAE;AAAA,EAC1D;AAGA,MAAI,IAAI,UAAU;AAChB,WAAO,OAAO,QAAQ,QAAQ,IAAI,QAAsB;AAAA,EAC1D;AAEA,UAAQ,eAAe;AACvB,SAAO;AACT;AAMA,eAAsB,eAAe,UAA6C;AAChF,QAAM,eAAe,QAAQ,QAAQ;AAErC,MAAI,aAAa,SAAS,UAAU,GAAG;AACrC,WAAO,gBAAgB,YAAY;AAAA,EACrC;AAEA,QAAM,OAAO,MAAM,aAAa,YAAY;AAC5C,SAAO,CAAC,IAAI;AACd;AAEA,eAAe,gBAAgB,UAA6C;AAC1E,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,MAAM,OAAO,wBAAwB;AACjD,qBAAiB,IAAI;AAAA,EACvB,QAAQ;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,MAAM,SAAS,UAAU,OAAO;AAC/C,SAAO,eAAe,QAAQ,QAAQ;AACxC;AAMA,eAAsB,cAAc,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,KAAK,MAAM,WAAW,GAAG;AACrD,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,KAAK,IAAI,KAAK,KAAK,MAAM,SAAS,MAAM,KAAK,GAAG,CAAC;AACvE,QAAM,SAAS,MAAM,UAAU,KAAK;AACpC,QAAM,MACJ,MAAM,YAAY,MAAM,QAAQ,MAAM,SAAS,KAAK,IAAI,QAAQ,eAAe,MAAM,MAAM;AAE7F,SAAO,MAAM,MAAM,OAAO,GAAG;AAC/B;","names":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
discoverFlows,
|
|
3
|
+
discoverStepFiles,
|
|
4
|
+
loadStepFiles,
|
|
5
|
+
loadTestSource
|
|
6
|
+
} from "./chunk-3TRMQCUT.js";
|
|
7
|
+
|
|
8
|
+
// src/core/validator.ts
|
|
9
|
+
import { stat } from "fs/promises";
|
|
10
|
+
import { dirname, resolve } from "path";
|
|
11
|
+
function isValidationIssue(result) {
|
|
12
|
+
return "error" in result;
|
|
13
|
+
}
|
|
14
|
+
function summarizeValidationResults(results) {
|
|
15
|
+
let errorCount = 0;
|
|
16
|
+
let warningCount = 0;
|
|
17
|
+
for (const r of results) {
|
|
18
|
+
if (isValidationIssue(r)) errorCount++;
|
|
19
|
+
else warningCount++;
|
|
20
|
+
}
|
|
21
|
+
return { errorCount, warningCount };
|
|
22
|
+
}
|
|
23
|
+
async function validateFlowFile(filePath) {
|
|
24
|
+
try {
|
|
25
|
+
const absolutePath = resolve(filePath);
|
|
26
|
+
const mod = await import(absolutePath);
|
|
27
|
+
if (!mod.default) {
|
|
28
|
+
return { file: filePath, error: "No default export found" };
|
|
29
|
+
}
|
|
30
|
+
const def = mod.default;
|
|
31
|
+
if (!def.name || typeof def.fn !== "function") {
|
|
32
|
+
return { file: filePath, error: "Invalid flow definition: missing name or fn" };
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return {
|
|
37
|
+
file: filePath,
|
|
38
|
+
error: `Failed to import: ${e instanceof Error ? e.message : String(e)}`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function validateFlows(paths) {
|
|
43
|
+
const errors = [];
|
|
44
|
+
for (const path of paths) {
|
|
45
|
+
const err = await validateFlowFile(path);
|
|
46
|
+
if (err) errors.push(err);
|
|
47
|
+
}
|
|
48
|
+
return errors;
|
|
49
|
+
}
|
|
50
|
+
var VALID_PLATFORMS = /* @__PURE__ */ new Set(["web", "android", "ios"]);
|
|
51
|
+
async function validateProject(flowDir) {
|
|
52
|
+
const errors = [];
|
|
53
|
+
let paths;
|
|
54
|
+
try {
|
|
55
|
+
paths = await discoverFlows(flowDir);
|
|
56
|
+
} catch {
|
|
57
|
+
errors.push({ file: flowDir, error: "Flow directory does not exist" });
|
|
58
|
+
return errors;
|
|
59
|
+
}
|
|
60
|
+
if (paths.length === 0) {
|
|
61
|
+
errors.push({ file: flowDir, error: "No flow files found" });
|
|
62
|
+
return errors;
|
|
63
|
+
}
|
|
64
|
+
const hasFeatureFiles = paths.some((path) => path.endsWith(".feature"));
|
|
65
|
+
if (hasFeatureFiles) {
|
|
66
|
+
const flowDirStats = await stat(resolve(flowDir)).catch(() => null);
|
|
67
|
+
const stepSearchDir = flowDirStats?.isDirectory() ? flowDir : dirname(flowDir);
|
|
68
|
+
const stepPaths = await discoverStepFiles(stepSearchDir);
|
|
69
|
+
if (stepPaths.length > 0) {
|
|
70
|
+
try {
|
|
71
|
+
await loadStepFiles(stepPaths);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
errors.push({
|
|
74
|
+
file: flowDir,
|
|
75
|
+
error: `Failed to load step definitions: ${e instanceof Error ? e.message : String(e)}`
|
|
76
|
+
});
|
|
77
|
+
return errors;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const flowNames = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const p of paths) {
|
|
83
|
+
try {
|
|
84
|
+
const defs = await loadTestSource(p);
|
|
85
|
+
for (const def of defs) {
|
|
86
|
+
if (!def?.name || typeof def.fn !== "function") {
|
|
87
|
+
errors.push({ file: p, error: "Invalid flow definition: missing name or fn" });
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const existing = flowNames.get(def.name);
|
|
91
|
+
if (existing) {
|
|
92
|
+
errors.push({
|
|
93
|
+
file: p,
|
|
94
|
+
error: `Duplicate flow name "${def.name}" (also in ${existing})`
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
flowNames.set(def.name, p);
|
|
98
|
+
}
|
|
99
|
+
if (def.config?.platforms) {
|
|
100
|
+
for (const plat of def.config.platforms) {
|
|
101
|
+
if (!VALID_PLATFORMS.has(plat)) {
|
|
102
|
+
errors.push({
|
|
103
|
+
file: p,
|
|
104
|
+
error: `Invalid platform "${plat}" - must be web, android, or ios`
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
errors.push({
|
|
112
|
+
file: p,
|
|
113
|
+
error: `Failed to load: ${e instanceof Error ? e.message : String(e)}`
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return errors;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
isValidationIssue,
|
|
122
|
+
summarizeValidationResults,
|
|
123
|
+
validateFlowFile,
|
|
124
|
+
validateFlows,
|
|
125
|
+
validateProject
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=chunk-5245YBLL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/validator.ts"],"sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { discoverFlows, discoverStepFiles, loadStepFiles, loadTestSource } from \"./runner.js\";\n\nexport interface ValidationError {\n file: string;\n error: string;\n}\n\nexport interface ValidationWarning {\n file: string;\n message: string;\n}\n\nexport type ValidationResult = ValidationError | ValidationWarning;\n\nexport function isValidationIssue(result: ValidationResult): result is ValidationError {\n return \"error\" in result;\n}\n\nexport function summarizeValidationResults(results: ValidationResult[]): {\n errorCount: number;\n warningCount: number;\n} {\n let errorCount = 0;\n let warningCount = 0;\n for (const r of results) {\n if (isValidationIssue(r)) errorCount++;\n else warningCount++;\n }\n return { errorCount, warningCount };\n}\n\nexport async function validateFlowFile(filePath: string): Promise<ValidationError | null> {\n try {\n const absolutePath = resolve(filePath);\n const mod = await import(absolutePath);\n if (!mod.default) {\n return { file: filePath, error: \"No default export found\" };\n }\n const def = mod.default;\n if (!def.name || typeof def.fn !== \"function\") {\n return { file: filePath, error: \"Invalid flow definition: missing name or fn\" };\n }\n return null;\n } catch (e) {\n return {\n file: filePath,\n error: `Failed to import: ${e instanceof Error ? e.message : String(e)}`,\n };\n }\n}\n\nexport async function validateFlows(paths: string[]): Promise<ValidationError[]> {\n const errors: ValidationError[] = [];\n for (const path of paths) {\n const err = await validateFlowFile(path);\n if (err) errors.push(err);\n }\n return errors;\n}\n\nconst VALID_PLATFORMS = new Set([\"web\", \"android\", \"ios\"]);\n\nexport async function validateProject(flowDir: string): Promise<ValidationResult[]> {\n const errors: ValidationError[] = [];\n\n // Check flow directory exists and has flows\n let paths: string[];\n try {\n paths = await discoverFlows(flowDir);\n } catch {\n errors.push({ file: flowDir, error: \"Flow directory does not exist\" });\n return errors;\n }\n\n if (paths.length === 0) {\n errors.push({ file: flowDir, error: \"No flow files found\" });\n return errors;\n }\n\n const hasFeatureFiles = paths.some((path) => path.endsWith(\".feature\"));\n if (hasFeatureFiles) {\n const flowDirStats = await stat(resolve(flowDir)).catch(() => null);\n const stepSearchDir = flowDirStats?.isDirectory() ? flowDir : dirname(flowDir);\n const stepPaths = await discoverStepFiles(stepSearchDir);\n if (stepPaths.length > 0) {\n try {\n await loadStepFiles(stepPaths);\n } catch (e) {\n errors.push({\n file: flowDir,\n error: `Failed to load step definitions: ${e instanceof Error ? e.message : String(e)}`,\n });\n return errors;\n }\n }\n }\n\n // Load flows and check for duplicates + invalid platforms\n const flowNames = new Map<string, string>(); // name -> file\n\n for (const p of paths) {\n try {\n const defs = await loadTestSource(p);\n for (const def of defs) {\n if (!def?.name || typeof def.fn !== \"function\") {\n errors.push({ file: p, error: \"Invalid flow definition: missing name or fn\" });\n continue;\n }\n\n const existing = flowNames.get(def.name);\n if (existing) {\n errors.push({\n file: p,\n error: `Duplicate flow name \"${def.name}\" (also in ${existing})`,\n });\n } else {\n flowNames.set(def.name, p);\n }\n\n if (def.config?.platforms) {\n for (const plat of def.config.platforms) {\n if (!VALID_PLATFORMS.has(plat)) {\n errors.push({\n file: p,\n error: `Invalid platform \"${plat}\" - must be web, android, or ios`,\n });\n }\n }\n }\n }\n } catch (e) {\n errors.push({\n file: p,\n error: `Failed to load: ${e instanceof Error ? e.message : String(e)}`,\n });\n }\n }\n\n return errors;\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,YAAY;AACrB,SAAS,SAAS,eAAe;AAe1B,SAAS,kBAAkB,QAAqD;AACrF,SAAO,WAAW;AACpB;AAEO,SAAS,2BAA2B,SAGzC;AACA,MAAI,aAAa;AACjB,MAAI,eAAe;AACnB,aAAW,KAAK,SAAS;AACvB,QAAI,kBAAkB,CAAC,EAAG;AAAA,QACrB;AAAA,EACP;AACA,SAAO,EAAE,YAAY,aAAa;AACpC;AAEA,eAAsB,iBAAiB,UAAmD;AACxF,MAAI;AACF,UAAM,eAAe,QAAQ,QAAQ;AACrC,UAAM,MAAM,MAAM,OAAO;AACzB,QAAI,CAAC,IAAI,SAAS;AAChB,aAAO,EAAE,MAAM,UAAU,OAAO,0BAA0B;AAAA,IAC5D;AACA,UAAM,MAAM,IAAI;AAChB,QAAI,CAAC,IAAI,QAAQ,OAAO,IAAI,OAAO,YAAY;AAC7C,aAAO,EAAE,MAAM,UAAU,OAAO,8CAA8C;AAAA,IAChF;AACA,WAAO;AAAA,EACT,SAA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AI,IAAoB;AAE1C,aAAW,KAAK,OAAO;AACrB,QAAI;AACF,YAAM,OAAO,MAAM,eAAe,CAAC;AACnC,iBAAW,OAAO,MAAM;AACtB,YAAI,CAAC,KAAK,QAAQ,OAAO,IAAI,OAAO,YAAY;AAC9C,iBAAO,KAAK,EAAE,MAAM,GAAG,OAAO,8CAA8C,CAAC;AAC7E;AAAA,QACF;AAEA,cAAM,WAAW,UAAU,IAAI,IAAI,IAAI;AACvC,YAAI,UAAU;AACZ,iBAAO,KAAK;AAAA,YACV,MAAM;AAAA,YACN,OAAO,wBAAwB,IAAI,IAAI,cAAc,QAAQ;AAAA,UAC/D,CAAC;AAAA,QACH,OAAO;AACL,oBAAU,IAAI,IAAI,MAAM,CAAC;AAAA,QAC3B;AAEA,YAAI,IAAI,QAAQ,WAAW;AACzB,qBAAW,QAAQ,IAAI,OAAO,WAAW;AACvC,gBAAI,CAAC,gBAAgB,IAAI,IAAI,GAAG;AAC9B,qBAAO,KAAK;AAAA,gBACV,MAAM;AAAA,gBACN,OAAO,qBAAqB,IAAI;AAAA,cAClC,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,GAAG;AACV,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,OAAO,mBAAmB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;AAAA,MACtE,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -47,20 +47,32 @@ var sauceLabsHelperSchema = z.object({
|
|
|
47
47
|
connect: sauceConnectSchema.optional(),
|
|
48
48
|
options: z.record(z.string(), z.unknown()).optional()
|
|
49
49
|
}).strict();
|
|
50
|
+
var storybookConfigSchema = z.object({
|
|
51
|
+
url: z.string().url().optional(),
|
|
52
|
+
iframePath: z.string().min(1).optional()
|
|
53
|
+
}).strict();
|
|
50
54
|
var appiumExecutionConfigSchema = z.object({
|
|
51
55
|
serverUrl: z.string().url().optional(),
|
|
52
56
|
capabilities: z.record(z.string(), z.unknown()).optional(),
|
|
57
|
+
platformCapabilities: z.object({
|
|
58
|
+
android: z.record(z.string(), z.unknown()).optional(),
|
|
59
|
+
ios: z.record(z.string(), z.unknown()).optional()
|
|
60
|
+
}).strict().optional(),
|
|
53
61
|
capabilitiesFile: z.string().min(1).optional(),
|
|
54
62
|
reportToProvider: z.boolean().optional(),
|
|
55
63
|
browserstack: browserStackHelperSchema.optional(),
|
|
56
64
|
saucelabs: sauceLabsHelperSchema.optional(),
|
|
57
|
-
cloudProvider: z.string().min(1).optional()
|
|
65
|
+
cloudProvider: z.string().min(1).optional(),
|
|
66
|
+
autoStart: z.boolean().optional(),
|
|
67
|
+
autoStartBinary: z.string().min(1).optional(),
|
|
68
|
+
autoStartArgs: z.array(z.string()).optional()
|
|
58
69
|
}).strict();
|
|
59
70
|
var webExecutionConfigSchema = z.object({
|
|
60
71
|
browser: z.enum(["chromium", "firefox", "webkit"]).optional(),
|
|
61
72
|
headless: z.boolean().optional(),
|
|
62
73
|
storageState: z.string().min(1).optional(),
|
|
63
|
-
verboseLogging: z.boolean().optional()
|
|
74
|
+
verboseLogging: z.boolean().optional(),
|
|
75
|
+
storybook: storybookConfigSchema.optional()
|
|
64
76
|
}).strict();
|
|
65
77
|
var executionConfigSchema = z.object({
|
|
66
78
|
mode: z.enum(["local", "appium"]).optional(),
|
|
@@ -78,11 +90,17 @@ var artifactConfigSchema = z.object({
|
|
|
78
90
|
jsErrors: z.boolean().optional(),
|
|
79
91
|
har: z.boolean().optional()
|
|
80
92
|
}).strict();
|
|
93
|
+
var deviceStateSchema = z.object({
|
|
94
|
+
language: z.string().min(1).optional(),
|
|
95
|
+
locale: z.string().min(1).optional(),
|
|
96
|
+
timeZone: z.string().min(1).optional()
|
|
97
|
+
}).strict();
|
|
81
98
|
var launchOptionsSchema = z.object({
|
|
82
99
|
clearState: z.boolean().optional(),
|
|
83
100
|
clearKeychain: z.boolean().optional(),
|
|
84
101
|
deepLink: z.string().min(1).optional(),
|
|
85
|
-
launchArguments: z.record(z.string(), z.unknown()).optional()
|
|
102
|
+
launchArguments: z.record(z.string(), z.unknown()).optional(),
|
|
103
|
+
deviceState: deviceStateSchema.optional()
|
|
86
104
|
}).strict();
|
|
87
105
|
var provConfigSchema = z.object({
|
|
88
106
|
apps: z.object({
|
|
@@ -99,6 +117,7 @@ var provConfigSchema = z.object({
|
|
|
99
117
|
typingDelay: z.number().nonnegative().optional(),
|
|
100
118
|
initialPollInterval: z.number().positive().optional(),
|
|
101
119
|
hierarchyCacheTtl: z.number().nonnegative().optional(),
|
|
120
|
+
snapshotMaxDepth: z.number().int().positive().optional(),
|
|
102
121
|
retryDelay: z.number().nonnegative().optional(),
|
|
103
122
|
workers: z.number().int().positive().optional()
|
|
104
123
|
}).strict().optional(),
|
|
@@ -114,7 +133,12 @@ var provConfigSchema = z.object({
|
|
|
114
133
|
afterAll: hookSchema.optional()
|
|
115
134
|
}).strict().optional(),
|
|
116
135
|
artifacts: artifactConfigSchema.optional(),
|
|
117
|
-
execution: executionConfigSchema.optional()
|
|
136
|
+
execution: executionConfigSchema.optional(),
|
|
137
|
+
visualRegression: z.object({
|
|
138
|
+
threshold: z.number().min(0).max(1).optional(),
|
|
139
|
+
maxDiffPixelRatio: z.number().min(0).max(1).optional(),
|
|
140
|
+
baselinesDir: z.string().optional()
|
|
141
|
+
}).optional()
|
|
118
142
|
}).strict();
|
|
119
143
|
function defineConfig(config) {
|
|
120
144
|
return config;
|
|
@@ -134,4 +158,4 @@ export {
|
|
|
134
158
|
validateConfig,
|
|
135
159
|
formatConfigValidationError
|
|
136
160
|
};
|
|
137
|
-
//# sourceMappingURL=chunk-
|
|
161
|
+
//# sourceMappingURL=chunk-7VOWF42B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/config.ts"],"sourcesContent":["import type { Platform } from \"./selector.js\";\nimport type { DeviceStateConfig, LaunchOptions } from \"../drivers/raw-driver.js\";\nimport { z, type ZodError } from \"zod\";\n\nexport type { DeviceStateConfig, LaunchOptions };\n\nexport interface IOSSigningConfig {\n /** Apple Development Team ID (from developer.apple.com or Xcode) */\n teamId: string;\n /** Code signing identity (default: \"Apple Development\") */\n signingIdentity?: string;\n}\n\nexport interface AppConfig {\n url?: string;\n packageName?: string;\n bundleId?: string;\n /** Path to .app or .ipa for auto-install on device/simulator */\n appPath?: string;\n /** iOS code signing config for physical devices */\n signing?: IOSSigningConfig;\n}\n\nexport type BrowserName = \"chromium\" | \"firefox\" | \"webkit\";\n\nexport type StorybookValue = string | number | boolean | null;\n\nexport interface StorybookConfig {\n /** Optional dedicated Storybook URL (falls back to apps.web.url when omitted) */\n url?: string;\n /** Preview iframe path used to render isolated stories (default: /iframe.html) */\n iframePath?: string;\n}\n\nexport interface WebExecutionConfig {\n browser?: BrowserName;\n headless?: boolean;\n /** Optional Playwright storage state JSON file to preload for web runs */\n storageState?: string;\n /** Print verbose Playwright runtime events to stdout for local web debugging */\n verboseLogging?: boolean;\n /** Optional Storybook config for isolated component/story flows in the browser runtime */\n storybook?: StorybookConfig;\n}\n\nexport interface CloudAppReferenceConfig {\n /** Existing remote app reference, e.g. bs://... or storage:... */\n id?: string;\n /** Local file path to upload when the provider supports managed upload */\n path?: string;\n /** Override the uploaded file name when the provider supports it */\n name?: string;\n}\n\nexport interface BrowserStackAppConfig extends CloudAppReferenceConfig {\n /** Stable BrowserStack app alias */\n customId?: string;\n}\n\nexport interface BrowserStackLocalConfig {\n enabled?: boolean;\n binary?: string;\n identifier?: string;\n args?: string[];\n}\n\nexport interface BrowserStackHelperConfig {\n app?: BrowserStackAppConfig;\n local?: BrowserStackLocalConfig;\n options?: Record<string, unknown>;\n}\n\nexport interface SauceConnectConfig {\n enabled?: boolean;\n binary?: string;\n tunnelName?: string;\n args?: string[];\n}\n\nexport interface SauceLabsHelperConfig {\n app?: CloudAppReferenceConfig;\n connect?: SauceConnectConfig;\n options?: Record<string, unknown>;\n}\n\nexport interface AppiumExecutionConfig {\n serverUrl?: string;\n capabilities?: Record<string, unknown>;\n /**\n * Platform-specific capabilities merged on top of `capabilities` when the\n * matching platform runs. Useful when you want different `appium:deviceName`\n * or `appium:platformVersion` for Android vs iOS.\n */\n platformCapabilities?: {\n android?: Record<string, unknown>;\n ios?: Record<string, unknown>;\n };\n capabilitiesFile?: string;\n reportToProvider?: boolean;\n browserstack?: BrowserStackHelperConfig;\n saucelabs?: SauceLabsHelperConfig;\n /** Path to a custom cloud provider module (default export must conform to CloudProvider interface). */\n cloudProvider?: string;\n /**\n * Opt in to having spana spawn a local `appium` subprocess for the\n * duration of the test run. Requires `appium` to be on PATH. When true,\n * `serverUrl` (if set) is ignored and a URL is assigned to the\n * auto-started server instead. Off by default — spana never spawns\n * background processes unless you ask.\n */\n autoStart?: boolean;\n /** Override the `appium` binary name. Default: \"appium\". */\n autoStartBinary?: string;\n /** Extra CLI args to forward to the spawned Appium process. */\n autoStartArgs?: readonly string[];\n}\n\nexport interface ExecutionConfig {\n mode?: \"local\" | \"appium\";\n web?: WebExecutionConfig;\n appium?: AppiumExecutionConfig;\n}\n\nexport interface ArtifactConfig {\n outputDir?: string;\n captureOnFailure?: boolean;\n captureOnSuccess?: boolean;\n captureSteps?: boolean;\n screenshot?: boolean;\n uiHierarchy?: boolean;\n consoleLogs?: boolean;\n jsErrors?: boolean;\n har?: boolean;\n}\n\nexport interface HookContext {\n app: unknown; // Will be typed properly when App is defined\n expect?: unknown;\n platform?: Platform;\n result?: unknown;\n summary?: unknown;\n}\n\nexport interface ProvConfig {\n apps?: {\n web?: AppConfig;\n android?: AppConfig;\n ios?: AppConfig;\n };\n defaults?: {\n waitTimeout?: number;\n pollInterval?: number;\n settleTimeout?: number;\n retries?: number;\n /** Pause after each action (tap, scroll) to let the UI settle. Default: 0 (disabled). */\n waitForIdleTimeout?: number;\n /** Delay between each character when typing. Default: 0 (instant). */\n typingDelay?: number;\n /** Starting poll interval for adaptive backoff. Default: 50ms. Set equal to pollInterval to disable adaptive backoff. */\n initialPollInterval?: number;\n /** Max age in ms before cached hierarchy is stale. Default: 100. Set to 0 to disable. */\n hierarchyCacheTtl?: number;\n /** Max depth for UI hierarchy snapshots on iOS. Default: 100. */\n snapshotMaxDepth?: number;\n /** Delay in ms between retry attempts of a failed flow. Default: 0 (immediate). */\n retryDelay?: number;\n /** Max workers per platform when using --parallel. */\n workers?: number;\n };\n platforms?: Platform[];\n /** Run platforms concurrently when they use independent resources. Default: false (serial). */\n parallelPlatforms?: boolean;\n flowDir?: string;\n launchOptions?: LaunchOptions;\n /**\n * Reporter names or module paths. Built-in: \"console\", \"json\", \"junit\", \"html\", \"allure\".\n * Custom reporters: provide a relative path (e.g., \"./reporters/slack.ts\") that default-exports\n * a Reporter object or a `(options: { outputDir: string }) => Reporter` factory function.\n */\n reporters?: string[];\n hooks?: {\n beforeAll?: (ctx: HookContext) => Promise<void>;\n beforeEach?: (ctx: HookContext) => Promise<void>;\n afterEach?: (ctx: HookContext) => Promise<void>;\n afterAll?: (ctx: HookContext) => Promise<void>;\n };\n artifacts?: ArtifactConfig;\n execution?: ExecutionConfig;\n visualRegression?: {\n threshold?: number;\n maxDiffPixelRatio?: number;\n baselinesDir?: string;\n };\n}\n\nconst platformSchema = z.enum([\"web\", \"android\", \"ios\"]);\nconst reporterSchema = z.string().min(1);\nconst hookSchema = z.custom<(...args: unknown[]) => Promise<void>>(\n (value) => typeof value === \"function\",\n { message: \"Expected function\" },\n);\n\nconst iosSigningConfigSchema = z\n .object({\n teamId: z.string().min(1, \"teamId is required\"),\n signingIdentity: z.string().min(1).optional(),\n })\n .strict();\n\nconst appConfigSchema = z\n .object({\n url: z.string().url().optional(),\n packageName: z.string().min(1).optional(),\n bundleId: z.string().min(1).optional(),\n appPath: z.string().min(1).optional(),\n signing: iosSigningConfigSchema.optional(),\n })\n .strict();\n\nconst cloudAppReferenceSchema = z\n .object({\n id: z.string().min(1).optional(),\n path: z.string().min(1).optional(),\n name: z.string().min(1).optional(),\n })\n .strict();\n\nconst browserStackAppSchema = cloudAppReferenceSchema\n .extend({\n customId: z.string().min(1).optional(),\n })\n .strict();\n\nconst browserStackLocalSchema = z\n .object({\n enabled: z.boolean().optional(),\n binary: z.string().min(1).optional(),\n identifier: z.string().min(1).optional(),\n args: z.array(z.string().min(1)).optional(),\n })\n .strict();\n\nconst browserStackHelperSchema = z\n .object({\n app: browserStackAppSchema.optional(),\n local: browserStackLocalSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .strict();\n\nconst sauceConnectSchema = z\n .object({\n enabled: z.boolean().optional(),\n binary: z.string().min(1).optional(),\n tunnelName: z.string().min(1).optional(),\n args: z.array(z.string().min(1)).optional(),\n })\n .strict();\n\nconst sauceLabsHelperSchema = z\n .object({\n app: cloudAppReferenceSchema.optional(),\n connect: sauceConnectSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .strict();\n\nconst storybookConfigSchema = z\n .object({\n url: z.string().url().optional(),\n iframePath: z.string().min(1).optional(),\n })\n .strict();\n\nconst appiumExecutionConfigSchema = z\n .object({\n serverUrl: z.string().url().optional(),\n capabilities: z.record(z.string(), z.unknown()).optional(),\n platformCapabilities: z\n .object({\n android: z.record(z.string(), z.unknown()).optional(),\n ios: z.record(z.string(), z.unknown()).optional(),\n })\n .strict()\n .optional(),\n capabilitiesFile: z.string().min(1).optional(),\n reportToProvider: z.boolean().optional(),\n browserstack: browserStackHelperSchema.optional(),\n saucelabs: sauceLabsHelperSchema.optional(),\n cloudProvider: z.string().min(1).optional(),\n autoStart: z.boolean().optional(),\n autoStartBinary: z.string().min(1).optional(),\n autoStartArgs: z.array(z.string()).optional(),\n })\n .strict();\n\nconst webExecutionConfigSchema = z\n .object({\n browser: z.enum([\"chromium\", \"firefox\", \"webkit\"]).optional(),\n headless: z.boolean().optional(),\n storageState: z.string().min(1).optional(),\n verboseLogging: z.boolean().optional(),\n storybook: storybookConfigSchema.optional(),\n })\n .strict();\n\nconst executionConfigSchema = z\n .object({\n mode: z.enum([\"local\", \"appium\"]).optional(),\n web: webExecutionConfigSchema.optional(),\n appium: appiumExecutionConfigSchema.optional(),\n })\n .strict();\n\nconst artifactConfigSchema = z\n .object({\n outputDir: z.string().min(1).optional(),\n captureOnFailure: z.boolean().optional(),\n captureOnSuccess: z.boolean().optional(),\n captureSteps: z.boolean().optional(),\n screenshot: z.boolean().optional(),\n uiHierarchy: z.boolean().optional(),\n consoleLogs: z.boolean().optional(),\n jsErrors: z.boolean().optional(),\n har: z.boolean().optional(),\n })\n .strict();\n\nconst deviceStateSchema = z\n .object({\n language: z.string().min(1).optional(),\n locale: z.string().min(1).optional(),\n timeZone: z.string().min(1).optional(),\n })\n .strict();\n\nconst launchOptionsSchema = z\n .object({\n clearState: z.boolean().optional(),\n clearKeychain: z.boolean().optional(),\n deepLink: z.string().min(1).optional(),\n launchArguments: z.record(z.string(), z.unknown()).optional(),\n deviceState: deviceStateSchema.optional(),\n })\n .strict();\n\nexport const provConfigSchema = z\n .object({\n apps: z\n .object({\n web: appConfigSchema.optional(),\n android: appConfigSchema.optional(),\n ios: appConfigSchema.optional(),\n })\n .strict()\n .optional(),\n defaults: z\n .object({\n waitTimeout: z.number().positive().optional(),\n pollInterval: z.number().positive().optional(),\n settleTimeout: z.number().nonnegative().optional(),\n retries: z.number().int().nonnegative().optional(),\n waitForIdleTimeout: z.number().nonnegative().optional(),\n typingDelay: z.number().nonnegative().optional(),\n initialPollInterval: z.number().positive().optional(),\n hierarchyCacheTtl: z.number().nonnegative().optional(),\n snapshotMaxDepth: z.number().int().positive().optional(),\n retryDelay: z.number().nonnegative().optional(),\n workers: z.number().int().positive().optional(),\n })\n .strict()\n .optional(),\n platforms: z.array(platformSchema).optional(),\n parallelPlatforms: z.boolean().optional(),\n flowDir: z.string().min(1).optional(),\n launchOptions: launchOptionsSchema.optional(),\n reporters: z.array(reporterSchema).optional(),\n hooks: z\n .object({\n beforeAll: hookSchema.optional(),\n beforeEach: hookSchema.optional(),\n afterEach: hookSchema.optional(),\n afterAll: hookSchema.optional(),\n })\n .strict()\n .optional(),\n artifacts: artifactConfigSchema.optional(),\n execution: executionConfigSchema.optional(),\n visualRegression: z\n .object({\n threshold: z.number().min(0).max(1).optional(),\n maxDiffPixelRatio: z.number().min(0).max(1).optional(),\n baselinesDir: z.string().optional(),\n })\n .optional(),\n })\n .strict();\n\nexport function defineConfig(config: ProvConfig): ProvConfig {\n return config;\n}\n\nexport function validateConfig(config: unknown): ProvConfig {\n return provConfigSchema.parse(config) as ProvConfig;\n}\n\nexport function formatConfigValidationError(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.length > 0 ? issue.path.join(\".\") : \"config\";\n return `- ${path}: ${issue.message}`;\n })\n .join(\"\\n\");\n}\n"],"mappings":";AAEA,SAAS,SAAwB;AAiMjC,IAAM,iBAAiB,EAAE,KAAK,CAAC,OAAO,WAAW,KAAK,CAAC;AACvD,IAAM,iBAAiB,EAAE,OAAO,EAAE,IAAI,CAAC;AACvC,IAAM,aAAa,EAAE;AAAA,EACnB,CAAC,UAAU,OAAO,UAAU;AAAA,EAC5B,EAAE,SAAS,oBAAoB;AACjC;AAEA,IAAM,yBAAyB,EAC5B,OAAO;AAAA,EACN,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,oBAAoB;AAAA,EAC9C,iBAAiB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAC9C,CAAC,EACA,OAAO;AAEV,IAAM,kBAAkB,EACrB,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC/B,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACxC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACrC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACpC,SAAS,uBAAuB,SAAS;AAC3C,CAAC,EACA,OAAO;AAEV,IAAM,0BAA0B,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EACpC,eAAe,oBAAoB,SAAS;AAAA,EAC5C,WAAW,EAAE,MAAM,cAAc,EAAE,SAAS;AAAA,EAC5C,OAAO,EACJ,OAAO;AAAA,IACN,WAAW,WAAW,SAAS;AAAA,IAC/B,YAAY,WAAW,SAAS;AAAA,IAChC,WAAW,WAAW,SAAS;AAAA,IAC/B,UAAU,WAAW,SAAS;AAAA,EAChC,CAAC,EACA,OAAO,EACP,SAAS;AAAA,EACZ,WAAW,qBAAqB,SAAS;AAAA,EACzC,WAAW,sBAAsB,SAAS;AAAA,EAC1C,kBAAkB,EACf,OAAO;AAAA,IACN,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,IAC7C,mBAAmB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,IACrD,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EACpC,CAAC,EACA,SAAS;AACd,CAAC,EACA,OAAO;AAEH,SAAS,aAAa,QAAgC;AAC3D,SAAO;AACT;AAEO,SAAS,eAAe,QAA6B;AAC1D,SAAO,iBAAiB,MAAM,MAAM;AACtC;AAEO,SAAS,4BAA4B,OAAyB;AACnE,SAAO,MAAM,OACV,IAAI,CAAC,UAAU;AACd,UAAM,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,KAAK,GAAG,IAAI;AAC5D,WAAO,KAAK,IAAI,KAAK,MAAM,OAAO;AAAA,EACpC,CAAC,EACA,KAAK,IAAI;AACd;","names":[]}
|
|
@@ -155,6 +155,52 @@ function adbClearApp(serial, packageName) {
|
|
|
155
155
|
if (!adb) throw new Error("adb not found");
|
|
156
156
|
execSync(`${adb} -s ${serial} shell pm clear ${packageName}`, { stdio: "ignore" });
|
|
157
157
|
}
|
|
158
|
+
var ADB_PROFILE_MAP = {
|
|
159
|
+
"2g": { speed: "gprs", delay: "gprs" },
|
|
160
|
+
edge: { speed: "edge", delay: "edge" },
|
|
161
|
+
"3g": { speed: "umts", delay: "umts" },
|
|
162
|
+
"4g": { speed: "lte", delay: "none" },
|
|
163
|
+
wifi: { speed: "full", delay: "none" }
|
|
164
|
+
};
|
|
165
|
+
function adbSetAirplaneMode(serial, enable) {
|
|
166
|
+
const adb = findADB();
|
|
167
|
+
if (!adb) throw new Error("adb not found");
|
|
168
|
+
execSync(`${adb} -s ${serial} shell cmd connectivity airplane-mode ${enable ? "enable" : "disable"}`);
|
|
169
|
+
}
|
|
170
|
+
function adbSetWifi(serial, enable) {
|
|
171
|
+
const adb = findADB();
|
|
172
|
+
if (!adb) throw new Error("adb not found");
|
|
173
|
+
execSync(`${adb} -s ${serial} shell svc wifi ${enable ? "enable" : "disable"}`);
|
|
174
|
+
}
|
|
175
|
+
function adbSetData(serial, enable) {
|
|
176
|
+
const adb = findADB();
|
|
177
|
+
if (!adb) throw new Error("adb not found");
|
|
178
|
+
execSync(`${adb} -s ${serial} shell svc data ${enable ? "enable" : "disable"}`);
|
|
179
|
+
}
|
|
180
|
+
function adbSetNetworkProfile(serial, profile) {
|
|
181
|
+
const adb = findADB();
|
|
182
|
+
if (!adb) throw new Error("adb not found");
|
|
183
|
+
const mapping = ADB_PROFILE_MAP[profile];
|
|
184
|
+
if (!mapping) throw new Error(`Unknown network profile "${profile}"`);
|
|
185
|
+
execSync(`${adb} -s ${serial} emu network speed ${mapping.speed}`);
|
|
186
|
+
execSync(`${adb} -s ${serial} emu network delay ${mapping.delay}`);
|
|
187
|
+
}
|
|
188
|
+
function adbSetCustomNetwork(serial, downloadKbps, uploadKbps, delayMs) {
|
|
189
|
+
const adb = findADB();
|
|
190
|
+
if (!adb) throw new Error("adb not found");
|
|
191
|
+
execSync(`${adb} -s ${serial} emu network speed ${downloadKbps}:${uploadKbps}`);
|
|
192
|
+
execSync(`${adb} -s ${serial} emu network delay ${delayMs}:${delayMs}`);
|
|
193
|
+
}
|
|
194
|
+
function adbResetNetwork(serial) {
|
|
195
|
+
const adb = findADB();
|
|
196
|
+
if (!adb) throw new Error("adb not found");
|
|
197
|
+
execSync(`${adb} -s ${serial} emu network speed full`);
|
|
198
|
+
execSync(`${adb} -s ${serial} emu network delay none`);
|
|
199
|
+
try {
|
|
200
|
+
execSync(`${adb} -s ${serial} shell cmd connectivity airplane-mode disable`);
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
}
|
|
158
204
|
function adbOpenLink(serial, url, packageName) {
|
|
159
205
|
const adb = findADB();
|
|
160
206
|
if (!adb) throw new Error("adb not found");
|
|
@@ -190,6 +236,13 @@ export {
|
|
|
190
236
|
adbLaunchApp,
|
|
191
237
|
adbForceStop,
|
|
192
238
|
adbClearApp,
|
|
239
|
+
ADB_PROFILE_MAP,
|
|
240
|
+
adbSetAirplaneMode,
|
|
241
|
+
adbSetWifi,
|
|
242
|
+
adbSetData,
|
|
243
|
+
adbSetNetworkProfile,
|
|
244
|
+
adbSetCustomNetwork,
|
|
245
|
+
adbResetNetwork,
|
|
193
246
|
adbOpenLink
|
|
194
247
|
};
|
|
195
|
-
//# sourceMappingURL=chunk-
|
|
248
|
+
//# sourceMappingURL=chunk-EWIR2GVV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/device/android.ts"],"sourcesContent":["import { execFileSync, execSync } from \"node:child_process\";\n\nexport interface AndroidDevice {\n serial: string;\n state: string; // \"device\", \"offline\", \"unauthorized\"\n type: \"emulator\" | \"device\";\n}\n\n/** Find the adb binary */\nexport function findADB(): string | null {\n // Check common locations\n const candidates = [\n \"adb\", // on PATH\n `${process.env.ANDROID_HOME}/platform-tools/adb`,\n `${process.env.ANDROID_SDK_ROOT}/platform-tools/adb`,\n \"/usr/local/bin/adb\",\n `${process.env.HOME}/Library/Android/sdk/platform-tools/adb`,\n ];\n\n for (const candidate of candidates) {\n if (!candidate) continue;\n try {\n execSync(`${candidate} version`, { stdio: \"ignore\" });\n return candidate;\n } catch {\n // try next\n }\n }\n return null;\n}\n\n/** List connected Android devices */\nexport function listAndroidDevices(): AndroidDevice[] {\n const adb = findADB();\n if (!adb) return [];\n\n try {\n const output = execSync(`${adb} devices`, { encoding: \"utf-8\" });\n return parseDeviceList(output);\n } catch {\n return [];\n }\n}\n\nfunction parseDeviceList(output: string): AndroidDevice[] {\n const devices: AndroidDevice[] = [];\n const lines = output.split(\"\\n\");\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"List of\")) continue;\n\n const parts = trimmed.split(/\\s+/);\n if (parts.length < 2) continue;\n\n const serial = parts[0]!;\n const state = parts[1]!;\n\n devices.push({\n serial,\n state,\n type: serial.startsWith(\"emulator-\") ? \"emulator\" : \"device\",\n });\n }\n\n return devices;\n}\n\nfunction shellQuote(value: string): string {\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\n/** Get first available (state === \"device\") Android device */\nexport function firstAndroidDevice(): AndroidDevice | null {\n const devices = listAndroidDevices();\n return devices.find((d) => d.state === \"device\") ?? null;\n}\n\n/** Find the emulator binary */\nexport function findEmulator(): string | null {\n const candidates = [\n \"emulator\",\n `${process.env.ANDROID_HOME}/emulator/emulator`,\n `${process.env.ANDROID_SDK_ROOT}/emulator/emulator`,\n `${process.env.HOME}/Library/Android/sdk/emulator/emulator`,\n ];\n for (const candidate of candidates) {\n if (!candidate) continue;\n try {\n execSync(`${candidate} -version`, { stdio: \"ignore\" });\n return candidate;\n } catch {\n // try next\n }\n }\n return null;\n}\n\n/** List available Android Virtual Devices */\nexport function listAVDs(): string[] {\n const emulator = findEmulator();\n if (!emulator) return [];\n try {\n const output = execSync(`${emulator} -list-avds`, { encoding: \"utf-8\" });\n return output\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean);\n } catch {\n return [];\n }\n}\n\n/**\n * Start an Android emulator and wait for it to boot.\n * Returns the device serial (e.g. \"emulator-5554\") once ready.\n */\nexport function startEmulator(avdName: string, timeoutMs = 60_000): string {\n const emulator = findEmulator();\n if (!emulator) throw new Error(\"Android emulator not found\");\n\n // Launch in background\n const { spawn } = require(\"node:child_process\") as typeof import(\"node:child_process\");\n const proc = spawn(emulator, [\"-avd\", avdName, \"-no-snapshot-save\", \"-no-audio\", \"-no-window\"], {\n detached: true,\n stdio: \"ignore\",\n });\n proc.unref();\n\n // Wait for device to appear in adb\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n const device = firstAndroidDevice();\n if (device) {\n // Wait for boot to complete\n try {\n const bootAnim = execSync(`${adb} -s ${device.serial} shell getprop sys.boot_completed`, {\n encoding: \"utf-8\",\n timeout: 5000,\n }).trim();\n if (bootAnim === \"1\") return device.serial;\n } catch {\n // not ready yet\n }\n }\n execSync(\"sleep 2\");\n }\n\n throw new Error(`Emulator \"${avdName}\" did not boot within ${timeoutMs / 1000}s`);\n}\n\n/**\n * Ensure an Android device is available.\n * If none connected, attempts to start the first available AVD.\n * Returns the device or null if no AVDs available.\n */\nexport function ensureAndroidDevice(timeoutMs = 60_000): AndroidDevice | null {\n const existing = firstAndroidDevice();\n if (existing) return existing;\n\n const avds = listAVDs();\n if (avds.length === 0) return null;\n\n console.log(`No Android device connected. Starting emulator \"${avds[0]}\"...`);\n const serial = startEmulator(avds[0]!, timeoutMs);\n return { serial, state: \"device\", type: \"emulator\" };\n}\n\n/** Forward a port from host to device via adb */\nexport function adbForward(serial: string, hostPort: number, devicePort: number): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} forward tcp:${hostPort} tcp:${devicePort}`);\n}\n\n/** Run adb shell command on device */\nexport function adbShell(serial: string, command: string): string {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n return execSync(`${adb} -s ${serial} shell ${command}`, { encoding: \"utf-8\" });\n}\n\n/** Install APK on device */\nexport function adbInstall(serial: string, apkPath: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} install -r ${apkPath}`, { stdio: \"ignore\" });\n}\n\n/** Launch an installed app via the launcher intent */\nexport function adbLaunchApp(serial: string, packageName: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(\n `${adb} -s ${serial} shell monkey -p ${packageName} -c android.intent.category.LAUNCHER 1`,\n { stdio: \"ignore\" },\n );\n}\n\n/** Force-stop an installed app */\nexport function adbForceStop(serial: string, packageName: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} shell am force-stop ${packageName}`, { stdio: \"ignore\" });\n}\n\n/** Clear app data and cache */\nexport function adbClearApp(serial: string, packageName: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} shell pm clear ${packageName}`, { stdio: \"ignore\" });\n}\n\n// ── Network control helpers ──────────────────────────────────────────\n\n/** Maps friendly profile names to ADB emulator network presets */\nexport const ADB_PROFILE_MAP: Record<string, { speed: string; delay: string }> = {\n \"2g\": { speed: \"gprs\", delay: \"gprs\" },\n edge: { speed: \"edge\", delay: \"edge\" },\n \"3g\": { speed: \"umts\", delay: \"umts\" },\n \"4g\": { speed: \"lte\", delay: \"none\" },\n wifi: { speed: \"full\", delay: \"none\" },\n};\n\n/** Toggle airplane mode on/off */\nexport function adbSetAirplaneMode(serial: string, enable: boolean): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} shell cmd connectivity airplane-mode ${enable ? \"enable\" : \"disable\"}`);\n}\n\n/** Toggle Wi-Fi on/off */\nexport function adbSetWifi(serial: string, enable: boolean): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} shell svc wifi ${enable ? \"enable\" : \"disable\"}`);\n}\n\n/** Toggle mobile data on/off */\nexport function adbSetData(serial: string, enable: boolean): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} shell svc data ${enable ? \"enable\" : \"disable\"}`);\n}\n\n/** Apply a named network profile (emulator only) */\nexport function adbSetNetworkProfile(serial: string, profile: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n const mapping = ADB_PROFILE_MAP[profile];\n if (!mapping) throw new Error(`Unknown network profile \"${profile}\"`);\n execSync(`${adb} -s ${serial} emu network speed ${mapping.speed}`);\n execSync(`${adb} -s ${serial} emu network delay ${mapping.delay}`);\n}\n\n/** Apply custom network throttling (emulator only) */\nexport function adbSetCustomNetwork(serial: string, downloadKbps: number, uploadKbps: number, delayMs: number): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} emu network speed ${downloadKbps}:${uploadKbps}`);\n execSync(`${adb} -s ${serial} emu network delay ${delayMs}:${delayMs}`);\n}\n\n/** Reset network to full speed and disable airplane mode */\nexport function adbResetNetwork(serial: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n execSync(`${adb} -s ${serial} emu network speed full`);\n execSync(`${adb} -s ${serial} emu network delay none`);\n try {\n execSync(`${adb} -s ${serial} shell cmd connectivity airplane-mode disable`);\n } catch {\n // best-effort: may fail on physical devices\n }\n}\n\n/** Open a deep link or URL on the device */\nexport function adbOpenLink(serial: string, url: string, packageName?: string): void {\n const adb = findADB();\n if (!adb) throw new Error(\"adb not found\");\n\n // FLAG_ACTIVITY_CLEAR_TOP (0x04000000) + FLAG_ACTIVITY_NEW_TASK (0x10000000)\n // ensures the deeplink resets the navigation stack\n const flags = 0x04000000 | 0x10000000;\n const command = [\n \"am\",\n \"start\",\n \"-W\",\n \"-a\",\n \"android.intent.action.VIEW\",\n \"-f\",\n String(flags),\n \"-d\",\n shellQuote(url),\n ];\n\n if (packageName) {\n command.push(shellQuote(packageName));\n }\n\n execFileSync(adb, [\"-s\", serial, \"shell\", command.join(\" \")], { stdio: \"ignore\" });\n}\n"],"mappings":";;;;;AAAA,SAAS,cAAc,gBAAgB;AAShC,SAAS,UAAyB;AAEvC,QAAM,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A,WAAW,GAAG;AAAA,EAChB;AAEA,MAAI,aAAa;AACf,YAAQ,KAAK,WAAW,WAAW,CAAC;AAAA,EACtC;AAEA,eAAa,KAAK,CAAC,MAAM,QAAQ,SAAS,QAAQ,KAAK,GAAG,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC;AACnF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatConfigValidationError,
|
|
3
3
|
validateConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7VOWF42B.js";
|
|
5
5
|
|
|
6
6
|
// src/cli/config-loader.ts
|
|
7
7
|
import { existsSync } from "fs";
|
|
@@ -38,6 +38,12 @@ function resolveConfigPaths(config, configPath) {
|
|
|
38
38
|
config.execution.appium.capabilitiesFile
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
+
if (config.execution?.appium?.cloudProvider) {
|
|
42
|
+
config.execution.appium.cloudProvider = resolveIfRelative(
|
|
43
|
+
configDir,
|
|
44
|
+
config.execution.appium.cloudProvider
|
|
45
|
+
);
|
|
46
|
+
}
|
|
41
47
|
if (config.execution?.web?.storageState) {
|
|
42
48
|
config.execution.web.storageState = resolveIfRelative(
|
|
43
49
|
configDir,
|
|
@@ -68,6 +74,12 @@ function resolveConfigPaths(config, configPath) {
|
|
|
68
74
|
config.execution.appium.saucelabs.connect.binary
|
|
69
75
|
);
|
|
70
76
|
}
|
|
77
|
+
if (config.visualRegression?.baselinesDir) {
|
|
78
|
+
config.visualRegression.baselinesDir = resolveIfRelative(
|
|
79
|
+
configDir,
|
|
80
|
+
config.visualRegression.baselinesDir
|
|
81
|
+
);
|
|
82
|
+
}
|
|
71
83
|
return config;
|
|
72
84
|
}
|
|
73
85
|
async function loadConfig(options = {}) {
|
|
@@ -111,4 +123,4 @@ ${formatConfigValidationError(error)}`,
|
|
|
111
123
|
export {
|
|
112
124
|
loadConfig
|
|
113
125
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
126
|
+
//# sourceMappingURL=chunk-FJAJ4YNC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/config-loader.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { ZodError } from \"zod\";\nimport { formatConfigValidationError, validateConfig, type ProvConfig } from \"../schemas/config.js\";\n\nconst DEFAULT_CONFIG_CANDIDATES = [\"spana.config.ts\", \"packages/spana/spana.config.ts\"];\n\nexport interface LoadConfigOptions {\n configPath?: string;\n allowMissing?: boolean;\n}\n\nexport interface LoadedConfig {\n config: ProvConfig;\n configPath?: string;\n}\n\nfunction resolveIfRelative(baseDir: string, value?: string): string | undefined {\n if (!value) {\n return value;\n }\n\n return isAbsolute(value) ? value : resolve(baseDir, value);\n}\n\nfunction resolveConfigPaths(config: ProvConfig, configPath: string): ProvConfig {\n const configDir = dirname(configPath);\n\n if (config.flowDir) {\n config.flowDir = resolveIfRelative(configDir, config.flowDir);\n }\n\n if (config.artifacts?.outputDir) {\n config.artifacts.outputDir = resolveIfRelative(configDir, config.artifacts.outputDir);\n }\n\n if (config.apps?.web?.appPath) {\n config.apps.web.appPath = resolveIfRelative(configDir, config.apps.web.appPath);\n }\n\n if (config.apps?.android?.appPath) {\n config.apps.android.appPath = resolveIfRelative(configDir, config.apps.android.appPath);\n }\n\n if (config.apps?.ios?.appPath) {\n config.apps.ios.appPath = resolveIfRelative(configDir, config.apps.ios.appPath);\n }\n\n if (config.execution?.appium?.capabilitiesFile) {\n config.execution.appium.capabilitiesFile = resolveIfRelative(\n configDir,\n config.execution.appium.capabilitiesFile,\n );\n }\n\n if (config.execution?.appium?.cloudProvider) {\n config.execution.appium.cloudProvider = resolveIfRelative(\n configDir,\n config.execution.appium.cloudProvider,\n );\n }\n\n if (config.execution?.web?.storageState) {\n config.execution.web.storageState = resolveIfRelative(\n configDir,\n config.execution.web.storageState,\n );\n }\n\n if (config.execution?.appium?.browserstack?.app?.path) {\n config.execution.appium.browserstack.app.path = resolveIfRelative(\n configDir,\n config.execution.appium.browserstack.app.path,\n );\n }\n\n if (config.execution?.appium?.browserstack?.local?.binary) {\n config.execution.appium.browserstack.local.binary = resolveIfRelative(\n configDir,\n config.execution.appium.browserstack.local.binary,\n );\n }\n\n if (config.execution?.appium?.saucelabs?.app?.path) {\n config.execution.appium.saucelabs.app.path = resolveIfRelative(\n configDir,\n config.execution.appium.saucelabs.app.path,\n );\n }\n\n if (config.execution?.appium?.saucelabs?.connect?.binary) {\n config.execution.appium.saucelabs.connect.binary = resolveIfRelative(\n configDir,\n config.execution.appium.saucelabs.connect.binary,\n );\n }\n\n if (config.visualRegression?.baselinesDir) {\n config.visualRegression.baselinesDir = resolveIfRelative(\n configDir,\n config.visualRegression.baselinesDir,\n );\n }\n\n return config;\n}\n\nexport async function loadConfig(options: LoadConfigOptions = {}): Promise<LoadedConfig> {\n const candidates = options.configPath\n ? [resolve(options.configPath)]\n : DEFAULT_CONFIG_CANDIDATES.map((candidate) => resolve(candidate));\n const foundPath = candidates.find((candidate) => existsSync(candidate));\n\n if (!foundPath) {\n if (options.allowMissing && !options.configPath) {\n return { config: {} };\n }\n\n if (options.configPath) {\n throw new Error(`Config file not found: ${resolve(options.configPath)}`);\n }\n\n throw new Error(`No config file found. Looked in: ${candidates.join(\", \")}`);\n }\n\n let moduleValue: Record<string, unknown>;\n try {\n moduleValue = (await import(pathToFileURL(foundPath).href)) as Record<string, unknown>;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to load config at ${foundPath}: ${message}`, { cause: error });\n }\n\n const rawConfig = (\"default\" in moduleValue ? moduleValue.default : moduleValue) as unknown;\n\n try {\n const config = validateConfig(rawConfig);\n return {\n config: resolveConfigPaths(config, foundPath),\n configPath: foundPath,\n };\n } catch (error) {\n if (error instanceof ZodError) {\n throw new Error(\n `Config validation failed for ${foundPath}:\\n${formatConfigValidationError(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