spana-test 0.1.0 → 0.2.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 +4 -1
- package/README.md +277 -86
- package/dist/agent/index.d.ts +34 -5
- package/dist/agent/index.js +14 -10
- package/dist/{chunk-RK4Z6C7M.js → chunk-3YR4GUGE.js} +3 -2
- package/dist/chunk-3YR4GUGE.js.map +1 -0
- package/dist/{chunk-WIJYK22K.js → chunk-AEKDFFPJ.js} +2 -2
- package/dist/chunk-BF37W5EG.js +125 -0
- package/dist/chunk-BF37W5EG.js.map +1 -0
- package/dist/chunk-EXLUY7KT.js +21 -0
- package/dist/chunk-EXLUY7KT.js.map +1 -0
- package/dist/chunk-FNDOEMOL.js +62 -0
- package/dist/chunk-FNDOEMOL.js.map +1 -0
- package/dist/chunk-HWFDXIXR.js +183 -0
- package/dist/chunk-HWFDXIXR.js.map +1 -0
- package/dist/chunk-IJIASIX5.js +314 -0
- package/dist/chunk-IJIASIX5.js.map +1 -0
- package/dist/chunk-KJPHH2TW.js +168 -0
- package/dist/chunk-KJPHH2TW.js.map +1 -0
- package/dist/{chunk-RJ5VPHVX.js → chunk-L7MFJF46.js} +16 -6
- package/dist/chunk-L7MFJF46.js.map +1 -0
- package/dist/{chunk-5XO6S7AI.js → chunk-MRH7SK52.js} +4 -4
- package/dist/chunk-MRH7SK52.js.map +1 -0
- package/dist/{chunk-53MUJUJY.js → chunk-P7JQRLP4.js} +5 -4
- package/dist/{chunk-53MUJUJY.js.map → chunk-P7JQRLP4.js.map} +1 -1
- package/dist/chunk-S2XNAKSO.js +1087 -0
- package/dist/chunk-S2XNAKSO.js.map +1 -0
- package/dist/{chunk-VDWWIVM6.js → chunk-S4R4OR7T.js} +108 -53
- package/dist/chunk-S4R4OR7T.js.map +1 -0
- package/dist/{chunk-V62HFH6E.js → chunk-SFBRFB2N.js} +14 -6
- package/dist/chunk-SFBRFB2N.js.map +1 -0
- package/dist/{chunk-PWEOJKUF.js → chunk-VNYF5BHX.js} +28 -7
- package/dist/chunk-VNYF5BHX.js.map +1 -0
- package/dist/chunk-WBU34APM.js +38 -0
- package/dist/chunk-WBU34APM.js.map +1 -0
- package/dist/{chunk-CKJQX73M.js → chunk-WQ4GXUUE.js} +921 -352
- package/dist/chunk-WQ4GXUUE.js.map +1 -0
- package/dist/chunk-YBZCOQXJ.js +311 -0
- package/dist/chunk-YBZCOQXJ.js.map +1 -0
- package/dist/cli.js +316 -40
- package/dist/cli.js.map +1 -1
- package/dist/{compiler-G75RIIYS.js → compiler-74VGKZO6.js} +2 -2
- package/dist/{compiler-G75RIIYS.js.map → compiler-74VGKZO6.js.map} +1 -1
- package/dist/config-loader-BJJ3IJJ7.js +9 -0
- package/dist/{console-FV4RJPO4.js → console-XWKUTP3D.js} +39 -7
- package/dist/console-XWKUTP3D.js.map +1 -0
- package/dist/{config-Dg9O0rcQ.d.ts → coordinator-BbUjvvnX.d.ts} +165 -1
- package/dist/{discover-RWBKI5IB.js → discover-KZKXHZZA.js} +3 -3
- package/dist/doctor-command-T2UX5RV5.js +732 -0
- package/dist/doctor-command-T2UX5RV5.js.map +1 -0
- package/dist/{element-CGteXiXB.d.ts → element-DZ0HyJ3C.d.ts} +2 -0
- package/dist/{flow-D-_tlLpp.d.ts → flow-BUC9Mf8W.d.ts} +38 -9
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-JP2HBIJQ.js → html-GE6Q4DCG.js} +23 -3
- package/dist/html-GE6Q4DCG.js.map +1 -0
- package/dist/index.d.ts +171 -3
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/{init-command-CELKL2CX.js → init-command-GVMRXIMY.js} +37 -21
- package/dist/init-command-GVMRXIMY.js.map +1 -0
- package/dist/init-flow-command-R76AXF4Z.js +34 -0
- package/dist/init-flow-command-R76AXF4Z.js.map +1 -0
- package/dist/{installer-R6NX7BYQ.js → installer-YZJ4DV3F.js} +4 -2
- package/dist/{ios-ZZU6DHH7.js → ios-ZW6XVNLG.js} +4 -2
- package/dist/json-KS67BZYU.js +39 -0
- package/dist/json-KS67BZYU.js.map +1 -0
- package/dist/{junit-UDY5JG22.js → junit-HLC62MK6.js} +2 -2
- package/dist/junit-HLC62MK6.js.map +1 -0
- package/dist/provider-A57C3MU6.js +12 -0
- package/dist/{redact-IDA3C4UH.js → redact-U72BUBBR.js} +2 -2
- package/dist/{redact-IDA3C4UH.js.map → redact-U72BUBBR.js.map} +1 -1
- package/dist/{runner-QEF6PJOE.js → runner-UXNHVVGG.js} +2 -2
- package/dist/{server-MMK7PZIH.js → server-W7OA3DDN.js} +49 -24
- package/dist/server-W7OA3DDN.js.map +1 -0
- package/dist/session-TMNOKYLG.js +17 -0
- package/dist/{studio-command-CDVPREMG.js → studio-command-6VHTHDUK.js} +2 -2
- package/dist/{test-command-SB5KYPQI.js → test-command-AHMOZLV4.js} +1280 -357
- package/dist/test-command-AHMOZLV4.js.map +1 -0
- package/dist/validator-35624P7S.js +20 -0
- package/package.json +1 -1
- package/studio-dist/assets/index-DC6DIXfl.js +188 -0
- package/studio-dist/assets/index-DDKsnBwD.css +1 -0
- package/studio-dist/index.html +2 -2
- package/dist/chunk-5XO6S7AI.js.map +0 -1
- package/dist/chunk-BZRLA4Z3.js +0 -82
- package/dist/chunk-BZRLA4Z3.js.map +0 -1
- package/dist/chunk-CKJQX73M.js.map +0 -1
- package/dist/chunk-PANFRTIU.js +0 -310
- package/dist/chunk-PANFRTIU.js.map +0 -1
- package/dist/chunk-PWEOJKUF.js.map +0 -1
- package/dist/chunk-RJ5VPHVX.js.map +0 -1
- package/dist/chunk-RK4Z6C7M.js.map +0 -1
- package/dist/chunk-U564GCO2.js +0 -259
- package/dist/chunk-U564GCO2.js.map +0 -1
- package/dist/chunk-V62HFH6E.js.map +0 -1
- package/dist/chunk-VDWWIVM6.js.map +0 -1
- package/dist/config-loader-JJ5RPP53.js +0 -9
- package/dist/console-FV4RJPO4.js.map +0 -1
- package/dist/html-JP2HBIJQ.js.map +0 -1
- package/dist/init-command-CELKL2CX.js.map +0 -1
- package/dist/json-JMRPUVY2.js +0 -20
- package/dist/json-JMRPUVY2.js.map +0 -1
- package/dist/junit-UDY5JG22.js.map +0 -1
- package/dist/provider-CUWPULGC.js +0 -10
- package/dist/server-MMK7PZIH.js.map +0 -1
- package/dist/session-FBJABNXL.js +0 -16
- package/dist/test-command-SB5KYPQI.js.map +0 -1
- package/dist/validator-CFQ55NUQ.js +0 -13
- package/studio-dist/assets/index-CPdpC9i-.css +0 -1
- package/studio-dist/assets/index-L1Wd0vop.js +0 -183
- /package/dist/{chunk-WIJYK22K.js.map → chunk-AEKDFFPJ.js.map} +0 -0
- /package/dist/{config-loader-JJ5RPP53.js.map → config-loader-BJJ3IJJ7.js.map} +0 -0
- /package/dist/{discover-RWBKI5IB.js.map → discover-KZKXHZZA.js.map} +0 -0
- /package/dist/{installer-R6NX7BYQ.js.map → installer-YZJ4DV3F.js.map} +0 -0
- /package/dist/{ios-ZZU6DHH7.js.map → ios-ZW6XVNLG.js.map} +0 -0
- /package/dist/{provider-CUWPULGC.js.map → provider-A57C3MU6.js.map} +0 -0
- /package/dist/{runner-QEF6PJOE.js.map → runner-UXNHVVGG.js.map} +0 -0
- /package/dist/{session-FBJABNXL.js.map → session-TMNOKYLG.js.map} +0 -0
- /package/dist/{studio-command-CDVPREMG.js.map → studio-command-6VHTHDUK.js.map} +0 -0
- /package/dist/{validator-CFQ55NUQ.js.map → validator-35624P7S.js.map} +0 -0
|
@@ -27,7 +27,7 @@ async function loadTestSource(filePath) {
|
|
|
27
27
|
async function loadFeatureFile(filePath) {
|
|
28
28
|
let compileFeature;
|
|
29
29
|
try {
|
|
30
|
-
const mod = await import("./compiler-
|
|
30
|
+
const mod = await import("./compiler-74VGKZO6.js");
|
|
31
31
|
compileFeature = mod.compileFeature;
|
|
32
32
|
} catch {
|
|
33
33
|
throw new Error(
|
|
@@ -61,7 +61,7 @@ async function discoverFlows(pathOrDir) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
await walk(absolute);
|
|
64
|
-
return results.
|
|
64
|
+
return results.toSorted();
|
|
65
65
|
}
|
|
66
66
|
async function discoverStepFiles(pathOrDir) {
|
|
67
67
|
const absolute = resolve(pathOrDir);
|
|
@@ -82,7 +82,7 @@ async function discoverStepFiles(pathOrDir) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
await walk(absolute);
|
|
85
|
-
return results.
|
|
85
|
+
return results.toSorted();
|
|
86
86
|
}
|
|
87
87
|
function filterFlows(flows, opts) {
|
|
88
88
|
return flows.filter((flow) => {
|
|
@@ -131,4 +131,4 @@ export {
|
|
|
131
131
|
filterFlows,
|
|
132
132
|
applyShard
|
|
133
133
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-MRH7SK52.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 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;A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
7
7
|
import { existsSync } from "fs";
|
|
@@ -87,7 +87,7 @@ async function loadConfig(options = {}) {
|
|
|
87
87
|
moduleValue = await import(pathToFileURL(foundPath).href);
|
|
88
88
|
} catch (error) {
|
|
89
89
|
const message = error instanceof Error ? error.message : String(error);
|
|
90
|
-
throw new Error(`Failed to load config at ${foundPath}: ${message}
|
|
90
|
+
throw new Error(`Failed to load config at ${foundPath}: ${message}`, { cause: error });
|
|
91
91
|
}
|
|
92
92
|
const rawConfig = "default" in moduleValue ? moduleValue.default : moduleValue;
|
|
93
93
|
try {
|
|
@@ -100,7 +100,8 @@ async function loadConfig(options = {}) {
|
|
|
100
100
|
if (error instanceof ZodError) {
|
|
101
101
|
throw new Error(
|
|
102
102
|
`Config validation failed for ${foundPath}:
|
|
103
|
-
${formatConfigValidationError(error)}
|
|
103
|
+
${formatConfigValidationError(error)}`,
|
|
104
|
+
{ cause: error }
|
|
104
105
|
);
|
|
105
106
|
}
|
|
106
107
|
throw error;
|
|
@@ -110,4 +111,4 @@ ${formatConfigValidationError(error)}`
|
|
|
110
111
|
export {
|
|
111
112
|
loadConfig
|
|
112
113
|
};
|
|
113
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-P7JQRLP4.js.map
|
|
@@ -1 +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?.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 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}
|
|
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?.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 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(error)}`,\n { cause: error },\n );\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,YAAY,eAAe;AAC7C,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAGzB,IAAM,4BAA4B,CAAC,mBAAmB,gCAAgC;AAYtF,SAAS,kBAAkB,SAAiB,OAAoC;AAC9E,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SAAO,WAAW,KAAK,IAAI,QAAQ,QAAQ,SAAS,KAAK;AAC3D;AAEA,SAAS,mBAAmB,QAAoB,YAAgC;AAC9E,QAAM,YAAY,QAAQ,UAAU;AAEpC,MAAI,OAAO,SAAS;AAClB,WAAO,UAAU,kBAAkB,WAAW,OAAO,OAAO;AAAA,EAC9D;AAEA,MAAI,OAAO,WAAW,WAAW;AAC/B,WAAO,UAAU,YAAY,kBAAkB,WAAW,OAAO,UAAU,SAAS;AAAA,EACtF;AAEA,MAAI,OAAO,MAAM,KAAK,SAAS;AAC7B,WAAO,KAAK,IAAI,UAAU,kBAAkB,WAAW,OAAO,KAAK,IAAI,OAAO;AAAA,EAChF;AAEA,MAAI,OAAO,MAAM,SAAS,SAAS;AACjC,WAAO,KAAK,QAAQ,UAAU,kBAAkB,WAAW,OAAO,KAAK,QAAQ,OAAO;AAAA,EACxF;AAEA,MAAI,OAAO,MAAM,KAAK,SAAS;AAC7B,WAAO,KAAK,IAAI,UAAU,kBAAkB,WAAW,OAAO,KAAK,IAAI,OAAO;AAAA,EAChF;AAEA,MAAI,OAAO,WAAW,QAAQ,kBAAkB;AAC9C,WAAO,UAAU,OAAO,mBAAmB;AAAA,MACzC;AAAA,MACA,OAAO,UAAU,OAAO;AAAA,IAC1B;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,KAAK,cAAc;AACvC,WAAO,UAAU,IAAI,eAAe;AAAA,MAClC;AAAA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