@step-forge/step-forge 0.0.21 → 0.0.23
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/RUNTIME.md +73 -12
- package/dist/analyzer-DIZPMxzN.cjs +441 -0
- package/dist/analyzer-DIZPMxzN.cjs.map +1 -0
- package/dist/analyzer-DnfK54Dw.js +417 -0
- package/dist/analyzer-DnfK54Dw.js.map +1 -0
- package/dist/analyzer-cli.js +1 -1
- package/dist/{analyzer-DYfdoSIS.js → analyzer-gYyAKIpM.js} +61 -25
- package/dist/analyzer-gYyAKIpM.js.map +1 -0
- package/dist/analyzer.d.ts +2 -0
- package/dist/analyzer.js +1 -1
- package/dist/cli.cjs +753 -84
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +751 -84
- package/dist/cli.js.map +1 -1
- package/dist/{hooks-Dar49TtT.d.ts → config-C7PCYgYy.d.cts} +65 -16
- package/dist/{hooks-Dar49TtT.d.cts → config-C7PCYgYy.d.ts} +65 -16
- package/dist/{engine-DPRxs6eC.js → engine-DPVLEHBi.js} +8 -26
- package/dist/engine-DPVLEHBi.js.map +1 -0
- package/dist/{engine-DWAIlwWp.cjs → engine-vqA-eL_T.cjs} +8 -26
- package/dist/engine-vqA-eL_T.cjs.map +1 -0
- package/dist/{gherkinParser-CHpkEwii.cjs → gherkinParser-_ZgvELdy.cjs} +142 -3
- package/dist/gherkinParser-_ZgvELdy.cjs.map +1 -0
- package/dist/{gherkinParser-CKARHgt4.js → gherkinParser-i-Q7M6mi.js} +98 -4
- package/dist/gherkinParser-i-Q7M6mi.js.map +1 -0
- package/dist/hooks-BDCMKeNq.js +71 -0
- package/dist/{hooks-CywugMQQ.js.map → hooks-BDCMKeNq.js.map} +1 -1
- package/dist/{hooks-CGYzwDOv.cjs → hooks-Be0cjULN.cjs} +20 -31
- package/dist/{hooks-CGYzwDOv.cjs.map → hooks-Be0cjULN.cjs.map} +1 -1
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +11 -48
- package/dist/runtime.d.ts +11 -48
- package/dist/runtime.js +3 -3
- package/dist/step-forge.cjs +22 -377
- package/dist/step-forge.cjs.map +1 -1
- package/dist/step-forge.d.cts +13 -4
- package/dist/step-forge.d.ts +13 -4
- package/dist/step-forge.js +17 -371
- package/dist/step-forge.js.map +1 -1
- package/package.json +2 -2
- package/dist/analyzer-DYfdoSIS.js.map +0 -1
- package/dist/engine-DPRxs6eC.js.map +0 -1
- package/dist/engine-DWAIlwWp.cjs.map +0 -1
- package/dist/gherkinParser-CHpkEwii.cjs.map +0 -1
- package/dist/gherkinParser-CKARHgt4.js.map +0 -1
- package/dist/hooks-CywugMQQ.js +0 -82
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../../src/runtime/config.ts","../../src/runtime/filter.ts","../../src/runtime/reporters.ts","../../src/runtime/runner.ts","../../src/runtime/cli.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { access } from \"node:fs/promises\";\n\n/**\n * User-facing runner configuration. The same shape is accepted from a\n * `step-forge.config.ts` file (default export) and from CLI flags, with flags\n * taking precedence. Everything is optional; {@link resolveConfig} fills in\n * defaults.\n */\nexport interface RunnerOptions {\n /** Feature-file glob(s), relative to `cwd`. Defaults to every `.feature` file. */\n features?: string | string[];\n /** Step-module glob(s), relative to `cwd`. Defaults to every `.steps.ts` file. */\n steps?: string | string[];\n /**\n * Module that default-exports a world factory `() => world`, relative to\n * `cwd`. When omitted each scenario gets a fresh `BasicWorld`.\n */\n world?: string;\n /**\n * Max scenarios in flight at once. Defaults to `1` (serial), matching\n * Cucumber's default execution model — scenarios often share module-level\n * state via hooks, which only holds under serial execution. Raise it to opt\n * into parallelism for isolated, I/O-bound suites.\n */\n concurrency?: number;\n /** Reporter name. Default `pretty`. */\n reporter?: \"pretty\" | \"progress\";\n /** Only run scenarios whose name matches this (string → substring/regex). */\n name?: string;\n /** Cucumber tag expression, e.g. `@smoke and not @wip`. */\n tags?: string;\n}\n\n/** Fully-resolved config: no optionals, globs kept as arrays, paths absolute. */\nexport interface ResolvedConfig {\n cwd: string;\n features: string[];\n steps: string[];\n world?: string;\n concurrency: number;\n reporter: \"pretty\" | \"progress\";\n name?: string;\n tags?: string;\n}\n\nconst DEFAULT_FEATURES = \"**/*.feature\";\nconst DEFAULT_STEPS = \"**/*.steps.ts\";\nconst CONFIG_BASENAMES = [\n \"step-forge.config.ts\",\n \"step-forge.config.mts\",\n \"step-forge.config.js\",\n \"step-forge.config.mjs\",\n];\n\nfunction toArray<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\nasync function exists(p: string): Promise<boolean> {\n try {\n await access(p);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Locate and import a `step-forge.config.*` file from `cwd`, returning its\n * default export (or `{}` if none is present). Imported by absolute file URL so\n * Bun transpiles the TypeScript config natively.\n */\nexport async function loadConfigFile(cwd: string): Promise<RunnerOptions> {\n for (const basename of CONFIG_BASENAMES) {\n const candidate = path.join(cwd, basename);\n if (!(await exists(candidate))) continue;\n const mod = await import(pathToFileURL(candidate).href);\n return (mod.default ?? mod) as RunnerOptions;\n }\n return {};\n}\n\n/**\n * Merge file config with CLI overrides and apply defaults. CLI overrides win\n * field-by-field; array globs are normalised to arrays and default when neither\n * source provides them.\n */\nexport function resolveConfig(\n cwd: string,\n file: RunnerOptions,\n cli: RunnerOptions\n): ResolvedConfig {\n const pick = <K extends keyof RunnerOptions>(key: K): RunnerOptions[K] =>\n cli[key] ?? file[key];\n\n const features = toArray(pick(\"features\"));\n const steps = toArray(pick(\"steps\"));\n\n return {\n cwd,\n features: features.length ? features : [DEFAULT_FEATURES],\n steps: steps.length ? steps : [DEFAULT_STEPS],\n world: pick(\"world\"),\n concurrency: pick(\"concurrency\") ?? 1,\n reporter: pick(\"reporter\") ?? \"pretty\",\n name: pick(\"name\"),\n tags: pick(\"tags\"),\n };\n}\n","import { ParsedScenario } from \"../analyzer/types\";\n\n/**\n * A predicate over a scenario's tags, compiled from a Cucumber tag expression.\n * Supports `and`, `or`, `not`, parentheses, and bare `@tag` atoms — the common\n * subset of Cucumber's tag-expression language. Kept dependency-free; swap for\n * `@cucumber/tag-expressions` if fuller parity is needed.\n */\nexport type TagPredicate = (tags: readonly string[]) => boolean;\n\n/** Tokenise a tag expression into atoms, operators, and parentheses. */\nfunction tokenize(expr: string): string[] {\n const tokens: string[] = [];\n const re = /\\s*(\\(|\\)|@[^\\s()]+|\\band\\b|\\bor\\b|\\bnot\\b)\\s*/gy;\n let index = 0;\n while (index < expr.length) {\n re.lastIndex = index;\n const m = re.exec(expr);\n if (!m || m.index !== index) {\n throw new Error(`Invalid tag expression near: ${expr.slice(index)}`);\n }\n tokens.push(m[1]);\n index = re.lastIndex;\n }\n return tokens;\n}\n\n/**\n * Compile a tag expression into a predicate via recursive descent\n * (or → and → not → primary). Throws on malformed input so a bad `--tags` flag\n * fails loudly rather than silently matching nothing.\n */\nexport function compileTagExpression(expr: string): TagPredicate {\n const tokens = tokenize(expr);\n let pos = 0;\n\n const peek = () => tokens[pos];\n const next = () => tokens[pos++];\n\n const parseOr = (): TagPredicate => {\n let left = parseAnd();\n while (peek() === \"or\") {\n next();\n const right = parseAnd();\n const l = left;\n left = tags => l(tags) || right(tags);\n }\n return left;\n };\n\n const parseAnd = (): TagPredicate => {\n let left = parseNot();\n while (peek() === \"and\") {\n next();\n const right = parseNot();\n const l = left;\n left = tags => l(tags) && right(tags);\n }\n return left;\n };\n\n const parseNot = (): TagPredicate => {\n if (peek() === \"not\") {\n next();\n const operand = parseNot();\n return tags => !operand(tags);\n }\n return parsePrimary();\n };\n\n const parsePrimary = (): TagPredicate => {\n const token = next();\n if (token === \"(\") {\n const inner = parseOr();\n if (next() !== \")\") throw new Error(\"Unbalanced parentheses in tags\");\n return inner;\n }\n if (token === undefined || !token.startsWith(\"@\")) {\n throw new Error(`Expected a tag, got: ${token ?? \"end of input\"}`);\n }\n return tags => tags.includes(token);\n };\n\n const predicate = parseOr();\n if (pos !== tokens.length) {\n throw new Error(`Unexpected token in tag expression: ${peek()}`);\n }\n return predicate;\n}\n\nexport interface SelectOptions {\n /** Substring or `/regex/flags` match against the scenario (or outline) name. */\n name?: string;\n /** Cucumber tag expression. */\n tags?: string;\n}\n\n/** Parse a `/pattern/flags` string into a RegExp, else treat it as a substring. */\nfunction toNameMatcher(name: string): (candidate: string) => boolean {\n const delim = /^\\/(.*)\\/([a-z]*)$/.exec(name);\n if (delim) {\n const re = new RegExp(delim[1], delim[2]);\n return candidate => re.test(candidate);\n }\n return candidate => candidate.includes(name);\n}\n\n/**\n * Narrow scenarios by name and tags, then apply `@only` focus. `@skip` is *not*\n * applied here — skipped scenarios stay in the set so the runner can report them\n * as skipped rather than silently dropping them. Returns scenarios in input\n * order.\n *\n * `@only` semantics mirror the Vitest plugin: if any surviving scenario is\n * tagged `@only` (and not `@skip`), the run is focused to just those.\n */\nexport function selectScenarios(\n scenarios: ParsedScenario[],\n options: SelectOptions\n): ParsedScenario[] {\n let selected = scenarios;\n\n if (options.name) {\n const matches = toNameMatcher(options.name);\n selected = selected.filter(\n s => matches(s.name) || (s.outline ? matches(s.outline.name) : false)\n );\n }\n\n if (options.tags) {\n const predicate = compileTagExpression(options.tags);\n selected = selected.filter(s => predicate(s.tags));\n }\n\n const focused = selected.filter(\n s => s.tags.includes(\"@only\") && !s.tags.includes(\"@skip\")\n );\n return focused.length ? focused : selected;\n}\n","import { relative } from \"node:path\";\nimport { ScenarioResult, StepResult } from \"./engine\";\n\n/**\n * A reporter observes the run. `onScenarioEnd` fires as each scenario finishes\n * (order is completion order, which under concurrency is non-deterministic);\n * `onComplete` fires once with every result for end-of-run summaries.\n */\nexport interface Reporter {\n onScenarioEnd?(result: ScenarioResult): void;\n onComplete(results: ScenarioResult[], durationMs: number): void;\n}\n\n// --- ANSI colouring -------------------------------------------------------\n// Honour NO_COLOR and non-TTY output; no dependency on a colour library.\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\n\nconst wrap = (open: number, close: number) => (s: string) =>\n useColor ? `\\x1b[${open}m${s}\\x1b[${close}m` : s;\n\nconst c = {\n green: wrap(32, 39),\n red: wrap(31, 39),\n yellow: wrap(33, 39),\n cyan: wrap(36, 39),\n dim: wrap(2, 22),\n bold: wrap(1, 22),\n};\n\nconst STATUS_MARK: Record<StepResult[\"status\"], string> = {\n passed: c.green(\"✓\"),\n failed: c.red(\"✗\"),\n skipped: c.yellow(\"-\"),\n};\n\n/** Indent every line of a block by `pad` spaces. */\nfunction indent(text: string, pad: number): string {\n const prefix = \" \".repeat(pad);\n return text\n .split(\"\\n\")\n .map(line => (line ? prefix + line : line))\n .join(\"\\n\");\n}\n\n/** Render one scenario as a Cucumber-style tree of steps. */\nfunction renderScenario(result: ScenarioResult): string {\n const lines: string[] = [];\n const label = result.scenario.outline\n ? `${result.scenario.outline.name} › ${result.scenario.name}`\n : result.scenario.name;\n lines.push(` Scenario: ${label}`);\n\n for (const step of result.scenario.steps) {\n const stepResult = result.steps.find(s => s.step === step);\n const status = stepResult?.status ?? \"skipped\";\n lines.push(\n ` ${STATUS_MARK[status]} ${c.dim(step.effectiveKeyword)} ${step.text}`\n );\n }\n\n if (result.error) {\n const stack = result.error.stack ?? String(result.error);\n lines.push(indent(c.red(stack), 6));\n }\n return lines.join(\"\\n\");\n}\n\n/** Group results by feature file, preserving first-seen order. */\nfunction groupByFeature(\n results: ScenarioResult[]\n): Map<string, ScenarioResult[]> {\n const groups = new Map<string, ScenarioResult[]>();\n for (const result of results) {\n const key = result.scenario.file;\n const bucket = groups.get(key);\n if (bucket) bucket.push(result);\n else groups.set(key, [result]);\n }\n return groups;\n}\n\ninterface Totals {\n scenarios: { passed: number; failed: number; skipped: number };\n steps: { passed: number; failed: number; skipped: number };\n}\n\nfunction tally(results: ScenarioResult[]): Totals {\n const totals: Totals = {\n scenarios: { passed: 0, failed: 0, skipped: 0 },\n steps: { passed: 0, failed: 0, skipped: 0 },\n };\n for (const result of results) {\n if (result.status === \"failed\") totals.scenarios.failed++;\n else if (result.steps.every(s => s.status === \"skipped\"))\n totals.scenarios.skipped++;\n else totals.scenarios.passed++;\n for (const step of result.steps) totals.steps[step.status]++;\n }\n return totals;\n}\n\n/** The shared end-of-run summary block: counts + duration. */\nfunction renderSummary(results: ScenarioResult[], durationMs: number): string {\n const t = tally(results);\n const scenarioTotal =\n t.scenarios.passed + t.scenarios.failed + t.scenarios.skipped;\n const stepTotal = t.steps.passed + t.steps.failed + t.steps.skipped;\n\n const part = (\n n: number,\n label: string,\n color: (s: string) => string\n ): string | null => (n > 0 ? color(`${n} ${label}`) : null);\n\n const scenarioParts = [\n part(t.scenarios.passed, \"passed\", c.green),\n part(t.scenarios.failed, \"failed\", c.red),\n part(t.scenarios.skipped, \"skipped\", c.yellow),\n ].filter((x): x is string => x !== null);\n\n const stepParts = [\n part(t.steps.passed, \"passed\", c.green),\n part(t.steps.failed, \"failed\", c.red),\n part(t.steps.skipped, \"skipped\", c.yellow),\n ].filter((x): x is string => x !== null);\n\n const seconds = (durationMs / 1000).toFixed(2);\n return [\n `${scenarioTotal} scenario${scenarioTotal === 1 ? \"\" : \"s\"} (${scenarioParts.join(\", \")})`,\n `${stepTotal} step${stepTotal === 1 ? \"\" : \"s\"} (${stepParts.join(\", \")})`,\n c.dim(`${seconds}s`),\n ].join(\"\\n\");\n}\n\n/**\n * Default reporter: prints the full feature → scenario → step tree grouped by\n * file, then the summary. Buffers to `onComplete` so concurrent scenarios don't\n * interleave mid-tree.\n */\nexport function prettyReporter(cwd: string = process.cwd()): Reporter {\n return {\n onComplete(results, durationMs) {\n const out: string[] = [];\n for (const [file, group] of groupByFeature(results)) {\n const featureName = group[0].scenario.file;\n out.push(c.bold(`Feature: ${relative(cwd, featureName || file)}`));\n for (const result of group) out.push(renderScenario(result));\n out.push(\"\");\n }\n out.push(renderSummary(results, durationMs));\n process.stdout.write(out.join(\"\\n\") + \"\\n\");\n },\n };\n}\n\n/**\n * Compact reporter: one character per scenario as it finishes (`.`/`F`/`-`),\n * then failures in detail and the summary. Best for large suites.\n */\nexport function progressReporter(cwd: string = process.cwd()): Reporter {\n return {\n onScenarioEnd(result) {\n const mark =\n result.status === \"failed\"\n ? c.red(\"F\")\n : result.steps.every(s => s.status === \"skipped\")\n ? c.yellow(\"-\")\n : c.green(\".\");\n process.stdout.write(mark);\n },\n onComplete(results, durationMs) {\n const failures = results.filter(r => r.status === \"failed\");\n const out: string[] = [\"\", \"\"];\n if (failures.length) {\n out.push(c.bold(\"Failures:\"), \"\");\n for (const result of failures) {\n out.push(\n c.bold(`Feature: ${relative(cwd, result.scenario.file)}`),\n renderScenario(result),\n \"\"\n );\n }\n }\n out.push(renderSummary(results, durationMs));\n process.stdout.write(out.join(\"\\n\") + \"\\n\");\n },\n };\n}\n\nexport function makeReporter(\n name: \"pretty\" | \"progress\",\n cwd?: string\n): Reporter {\n return name === \"progress\" ? progressReporter(cwd) : prettyReporter(cwd);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { ParsedScenario } from \"../analyzer/types\";\nimport { parseFeatureFiles } from \"../analyzer/gherkinParser\";\nimport { globFiles } from \"../globFiles\";\nimport { BasicWorld, MergeableWorld } from \"../world\";\nimport {\n compileRegistry,\n CompiledStep,\n runScenario,\n ScenarioResult,\n} from \"./engine\";\nimport { ensureGlobalHooks, globalHookRegistry, runHooks } from \"./hooks\";\nimport { globalRegistry } from \"./registry\";\nimport { selectScenarios } from \"./filter\";\nimport { makeReporter, Reporter } from \"./reporters\";\nimport { ResolvedConfig } from \"./config\";\n\ntype WorldFactory = () => MergeableWorld<any, any, any>;\n\n/**\n * Import every step-definition module so its `.step(...)` calls self-register\n * into the shared `globalRegistry`. Imported by file URL so Bun transpiles the\n * TypeScript natively.\n */\nasync function importSteps(files: string[]): Promise<void> {\n for (const file of files) {\n await import(pathToFileURL(file).href);\n }\n}\n\n/** Load the configured world factory, or default to a fresh `BasicWorld`. */\nasync function loadWorldFactory(\n world: string | undefined,\n cwd: string\n): Promise<WorldFactory> {\n if (!world) return () => new BasicWorld();\n const resolved = path.resolve(cwd, world);\n const mod = await import(pathToFileURL(resolved).href);\n const factory = mod.default ?? mod;\n if (typeof factory !== \"function\") {\n throw new Error(\n `World module ${world} must default-export a factory function () => world`\n );\n }\n return factory as WorldFactory;\n}\n\n/** A scenario carrying `@skip` never runs: report it with all steps skipped. */\nfunction skippedResult(scenario: ParsedScenario): ScenarioResult {\n return {\n scenario,\n status: \"passed\",\n steps: scenario.steps.map(step => ({ step, status: \"skipped\" as const })),\n };\n}\n\n/**\n * Run `items` through `worker`, at most `limit` in flight. Results come back in\n * input order even though completion order is not deterministic. A minimal\n * dependency-free pool — the whole point of the single-process model.\n */\nasync function runPool<T, R>(\n items: T[],\n limit: number,\n worker: (item: T, index: number) => Promise<R>\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n let cursor = 0;\n const runNext = async (): Promise<void> => {\n while (cursor < items.length) {\n const index = cursor++;\n results[index] = await worker(items[index], index);\n }\n };\n const workers = Array.from(\n { length: Math.min(Math.max(1, limit), items.length) },\n runNext\n );\n await Promise.all(workers);\n return results;\n}\n\nexport interface RunResult {\n results: ScenarioResult[];\n passed: boolean;\n durationMs: number;\n}\n\n/**\n * Execute a whole run end to end: discover and import steps, load the world,\n * parse and select scenarios, then run them concurrently against a\n * compiled-once step table with global/feature hooks around the batch. Never\n * throws for test failures — inspect `RunResult.passed`.\n */\nexport async function run(\n config: ResolvedConfig,\n reporter: Reporter = makeReporter(config.reporter, config.cwd)\n): Promise<RunResult> {\n const start =\n typeof performance !== \"undefined\" ? performance.now() : Date.now();\n\n const [featureFiles, stepFiles] = await Promise.all([\n globFiles(config.features, config.cwd),\n globFiles(config.steps, config.cwd),\n ]);\n\n await importSteps(stepFiles);\n const makeWorld = await loadWorldFactory(config.world, config.cwd);\n\n const compiled: CompiledStep[] = compileRegistry(globalRegistry);\n const allScenarios = parseFeatureFiles(featureFiles);\n const selected = selectScenarios(allScenarios, {\n name: config.name,\n tags: config.tags,\n });\n\n // Global before-hooks once; feature before/after bracket the whole batch.\n // (Hooks aren't file-scoped in the registry, so per-file bracketing would be\n // meaningless under concurrent execution.)\n await ensureGlobalHooks(globalHookRegistry);\n await runHooks(\"feature\", \"before\", globalHookRegistry);\n\n const results = await runPool(\n selected,\n config.concurrency,\n async scenario => {\n const result = scenario.tags.includes(\"@skip\")\n ? skippedResult(scenario)\n : await runScenario(scenario, compiled, makeWorld, globalHookRegistry);\n reporter.onScenarioEnd?.(result);\n return result;\n }\n );\n\n await runHooks(\"feature\", \"after\", globalHookRegistry);\n\n const durationMs =\n (typeof performance !== \"undefined\" ? performance.now() : Date.now()) -\n start;\n reporter.onComplete(results, durationMs);\n\n return {\n results,\n passed: results.every(r => r.status !== \"failed\"),\n durationMs,\n };\n}\n","#!/usr/bin/env bun\nimport { parseArgs } from \"node:util\";\nimport * as path from \"node:path\";\nimport { loadConfigFile, resolveConfig, RunnerOptions } from \"./config\";\nimport { run } from \"./runner\";\n\nconst HELP = `step-forge — native TypeScript runner for Gherkin step definitions\n\nUsage:\n step-forge [options] [feature globs...]\n\nOptions:\n -t, --tags <expr> Tag expression, e.g. \"@smoke and not @wip\"\n -n, --name <pattern> Only scenarios whose name matches (substring or /regex/)\n -s, --steps <glob> Step-definition module glob (repeatable)\n -w, --world <module> World factory module (default export () => world)\n -c, --concurrency <n> Max scenarios in flight (default: 1, i.e. serial)\n -r, --reporter <name> \"pretty\" (default) or \"progress\"\n --config <path> Config file directory (default: cwd)\n -h, --help Show this help\n\nPositional arguments are feature globs and override the configured features.\n`;\n\n/** Parse argv into config overrides. Positional args become feature globs. */\nfunction parseCli(argv: string[]): { cwd: string; overrides: RunnerOptions } {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n tags: { type: \"string\", short: \"t\" },\n name: { type: \"string\", short: \"n\" },\n steps: { type: \"string\", short: \"s\", multiple: true },\n world: { type: \"string\", short: \"w\" },\n concurrency: { type: \"string\", short: \"c\" },\n reporter: { type: \"string\", short: \"r\" },\n config: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\" },\n },\n });\n\n if (values.help) {\n process.stdout.write(HELP);\n process.exit(0);\n }\n\n const overrides: RunnerOptions = {};\n if (positionals.length) overrides.features = positionals;\n if (values.tags) overrides.tags = values.tags;\n if (values.name) overrides.name = values.name;\n if (values.steps) overrides.steps = values.steps;\n if (values.world) overrides.world = values.world;\n if (values.reporter) {\n if (values.reporter !== \"pretty\" && values.reporter !== \"progress\") {\n throw new Error(`Unknown reporter: ${values.reporter}`);\n }\n overrides.reporter = values.reporter;\n }\n if (values.concurrency !== undefined) {\n const n = Number(values.concurrency);\n if (!Number.isInteger(n) || n < 1) {\n throw new Error(`--concurrency must be a positive integer`);\n }\n overrides.concurrency = n;\n }\n\n const cwd = values.config\n ? path.resolve(process.cwd(), values.config)\n : process.cwd();\n return { cwd, overrides };\n}\n\nasync function main(): Promise<void> {\n const { cwd, overrides } = parseCli(process.argv.slice(2));\n const fileConfig = await loadConfigFile(cwd);\n const config = resolveConfig(cwd, fileConfig, overrides);\n const { passed } = await run(config);\n process.exitCode = passed ? 0 : 1;\n}\n\nmain().catch(err => {\n process.stderr.write(`${err instanceof Error ? err.stack : String(err)}\\n`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;AA+CA,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;AACF;AAEA,SAAS,QAAW,OAAiC;CACnD,IAAI,UAAU,KAAA,GAAW,OAAO,CAAC;CACjC,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;AAEA,eAAe,OAAO,GAA6B;CACjD,IAAI;EACF,MAAM,OAAO,CAAC;EACd,OAAO;CACT,QAA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AAa,YAAY,OAAO,aAAa,YACtD,MAAM,IAAI,MAAM,qBAAqB,OAAO,UAAU;EAExD,UAAU,WAAW,OAAO;CAC9B;CACA,IAAI,OAAO,gBAAgB,KAAA,GAAW;EACpC,MAAM,IAAI,OAAO,OAAO,WAAW;EACnC,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,GAC9B,MAAM,IAAI,MAAM,0CAA0C;EAE5D,UAAU,cAAc;CAC1B;CAKA,OAAO;EAAE,KAHG,OAAO,SACf,KAAK,QAAQ,QAAQ,IAAI,GAAG,OAAO,MAAM,IACzC,QAAQ,IAAI;EACF;CAAU;AAC1B;AAEA,eAAe,OAAsB;CACnC,MAAM,EAAE,KAAK,cAAc,SAAS,QAAQ,KAAK,MAAM,CAAC,CAAC;CAGzD,MAAM,EAAE,WAAW,MAAM,IADV,cAAc,KAAK,MADT,eAAe,GAAG,GACG,SACZ,CAAC;CACnC,QAAQ,WAAW,SAAS,IAAI;AAClC;AAEA,KAAK,CAAC,CAAC,OAAM,QAAO;CAClB,QAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,EAAE,GAAG;CAC1E,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":["useColor","wrap","write","useColor"],"sources":["../../src/runtime/config.ts","../../src/runtime/filter.ts","../../src/runtime/reporters.ts","../../src/runtime/runner.ts","../../src/runtime/prompt.ts","../../src/runtime/watcher.ts","../../src/runtime/interactive.ts","../../src/runtime/cli.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { access } from \"node:fs/promises\";\n\n/**\n * User-facing runner configuration. The same shape is accepted from a\n * `step-forge.config.ts` file (default export) and from CLI flags, with flags\n * taking precedence. Everything is optional; {@link resolveConfig} fills in\n * defaults.\n */\nexport interface RunnerOptions {\n /** Feature-file glob(s), relative to `cwd`. Defaults to every `.feature` file. */\n features?: string | string[];\n /** Step-module glob(s), relative to `cwd`. Defaults to every `.steps.ts` file. */\n steps?: string | string[];\n /**\n * Module that default-exports a world factory `() => world`, relative to\n * `cwd`. When omitted each scenario gets a fresh `BasicWorld`.\n */\n world?: string;\n /**\n * Max scenarios in flight at once. Defaults to `1` (serial), matching\n * Cucumber's default execution model — scenarios often share module-level\n * state via hooks, which only holds under serial execution. Raise it to opt\n * into parallelism for isolated, I/O-bound suites.\n */\n concurrency?: number;\n /** Reporter name. Default `pretty`. */\n reporter?: \"pretty\" | \"progress\";\n /**\n * Verbose output: report every scenario (pass, fail, skip) instead of only\n * failures. Passed to whichever reporter is active. Default `false`.\n */\n verbose?: boolean;\n /** Only run scenarios whose name matches this (string → substring/regex). */\n name?: string;\n /** Cucumber tag expression, e.g. `@smoke and not @wip`. */\n tags?: string;\n}\n\n/** Fully-resolved config: no optionals, globs kept as arrays, paths absolute. */\nexport interface ResolvedConfig {\n cwd: string;\n features: string[];\n steps: string[];\n world?: string;\n concurrency: number;\n reporter: \"pretty\" | \"progress\";\n verbose: boolean;\n name?: string;\n tags?: string;\n}\n\nconst DEFAULT_FEATURES = \"**/*.feature\";\nconst DEFAULT_STEPS = \"**/*.steps.ts\";\nconst CONFIG_BASENAMES = [\n \"step-forge.config.ts\",\n \"step-forge.config.mts\",\n \"step-forge.config.js\",\n \"step-forge.config.mjs\",\n];\n\nfunction toArray<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\nasync function exists(p: string): Promise<boolean> {\n try {\n await access(p);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Locate and import a `step-forge.config.*` file from `cwd`, returning its\n * default export (or `{}` if none is present). Imported by absolute file URL so\n * Bun transpiles the TypeScript config natively.\n */\nexport async function loadConfigFile(cwd: string): Promise<RunnerOptions> {\n for (const basename of CONFIG_BASENAMES) {\n const candidate = path.join(cwd, basename);\n if (!(await exists(candidate))) continue;\n const mod = await import(pathToFileURL(candidate).href);\n return (mod.default ?? mod) as RunnerOptions;\n }\n return {};\n}\n\n/**\n * Merge file config with CLI overrides and apply defaults. CLI overrides win\n * field-by-field; array globs are normalised to arrays and default when neither\n * source provides them.\n */\nexport function resolveConfig(\n cwd: string,\n file: RunnerOptions,\n cli: RunnerOptions\n): ResolvedConfig {\n const pick = <K extends keyof RunnerOptions>(key: K): RunnerOptions[K] =>\n cli[key] ?? file[key];\n\n const features = toArray(pick(\"features\"));\n const steps = toArray(pick(\"steps\"));\n\n return {\n cwd,\n features: features.length ? features : [DEFAULT_FEATURES],\n steps: steps.length ? steps : [DEFAULT_STEPS],\n world: pick(\"world\"),\n concurrency: pick(\"concurrency\") ?? 1,\n reporter: pick(\"reporter\") ?? \"pretty\",\n verbose: pick(\"verbose\") ?? false,\n name: pick(\"name\"),\n tags: pick(\"tags\"),\n };\n}\n","import { ParsedScenario } from \"../analyzer/types\";\n\n/**\n * A predicate over a scenario's tags, compiled from a Cucumber tag expression.\n * Supports `and`, `or`, `not`, parentheses, and bare `@tag` atoms — the common\n * subset of Cucumber's tag-expression language. Kept dependency-free; swap for\n * `@cucumber/tag-expressions` if fuller parity is needed.\n */\nexport type TagPredicate = (tags: readonly string[]) => boolean;\n\n/** Tokenise a tag expression into atoms, operators, and parentheses. */\nfunction tokenize(expr: string): string[] {\n const tokens: string[] = [];\n const re = /\\s*(\\(|\\)|@[^\\s()]+|\\band\\b|\\bor\\b|\\bnot\\b)\\s*/gy;\n let index = 0;\n while (index < expr.length) {\n re.lastIndex = index;\n const m = re.exec(expr);\n if (!m || m.index !== index) {\n throw new Error(`Invalid tag expression near: ${expr.slice(index)}`);\n }\n tokens.push(m[1]);\n index = re.lastIndex;\n }\n return tokens;\n}\n\n/**\n * Compile a tag expression into a predicate via recursive descent\n * (or → and → not → primary). Throws on malformed input so a bad `--tags` flag\n * fails loudly rather than silently matching nothing.\n */\nexport function compileTagExpression(expr: string): TagPredicate {\n const tokens = tokenize(expr);\n let pos = 0;\n\n const peek = () => tokens[pos];\n const next = () => tokens[pos++];\n\n const parseOr = (): TagPredicate => {\n let left = parseAnd();\n while (peek() === \"or\") {\n next();\n const right = parseAnd();\n const l = left;\n left = tags => l(tags) || right(tags);\n }\n return left;\n };\n\n const parseAnd = (): TagPredicate => {\n let left = parseNot();\n while (peek() === \"and\") {\n next();\n const right = parseNot();\n const l = left;\n left = tags => l(tags) && right(tags);\n }\n return left;\n };\n\n const parseNot = (): TagPredicate => {\n if (peek() === \"not\") {\n next();\n const operand = parseNot();\n return tags => !operand(tags);\n }\n return parsePrimary();\n };\n\n const parsePrimary = (): TagPredicate => {\n const token = next();\n if (token === \"(\") {\n const inner = parseOr();\n if (next() !== \")\") throw new Error(\"Unbalanced parentheses in tags\");\n return inner;\n }\n if (token === undefined || !token.startsWith(\"@\")) {\n throw new Error(`Expected a tag, got: ${token ?? \"end of input\"}`);\n }\n return tags => tags.includes(token);\n };\n\n const predicate = parseOr();\n if (pos !== tokens.length) {\n throw new Error(`Unexpected token in tag expression: ${peek()}`);\n }\n return predicate;\n}\n\nexport interface SelectOptions {\n /** Substring or `/regex/flags` match against the scenario (or outline) name. */\n name?: string;\n /** Cucumber tag expression. */\n tags?: string;\n}\n\n/** Parse a `/pattern/flags` string into a RegExp, else treat it as a substring. */\nfunction toNameMatcher(name: string): (candidate: string) => boolean {\n const delim = /^\\/(.*)\\/([a-z]*)$/.exec(name);\n if (delim) {\n const re = new RegExp(delim[1], delim[2]);\n return candidate => re.test(candidate);\n }\n return candidate => candidate.includes(name);\n}\n\n/**\n * Narrow scenarios by name and tags, then apply `@only` focus. `@skip` is *not*\n * applied here — skipped scenarios stay in the set so the runner can report them\n * as skipped rather than silently dropping them. Returns scenarios in input\n * order.\n *\n * `@only` semantics mirror the Vitest plugin: if any surviving scenario is\n * tagged `@only` (and not `@skip`), the run is focused to just those.\n */\nexport function selectScenarios(\n scenarios: ParsedScenario[],\n options: SelectOptions\n): ParsedScenario[] {\n let selected = scenarios;\n\n if (options.name) {\n const matches = toNameMatcher(options.name);\n selected = selected.filter(\n s => matches(s.name) || (s.outline ? matches(s.outline.name) : false)\n );\n }\n\n if (options.tags) {\n const predicate = compileTagExpression(options.tags);\n selected = selected.filter(s => predicate(s.tags));\n }\n\n const focused = selected.filter(\n s => s.tags.includes(\"@only\") && !s.tags.includes(\"@skip\")\n );\n return focused.length ? focused : selected;\n}\n","import { relative } from \"node:path\";\nimport { relativeFrame, relativeLocation, userFrames } from \"../sourceLocation\";\nimport { ScenarioResult, StepResult } from \"./engine\";\n\n/**\n * A reporter observes the run. `onScenarioEnd` fires as each scenario finishes\n * (completion order, non-deterministic under concurrency); `onComplete` fires\n * once with every result for the end-of-run output.\n *\n * Every reporter accepts a `verbose` flag: without it a reporter reports only\n * failures (plus a summary); with it, it reports every scenario. A reporter may\n * render the same either way — `verbose` is a request, not a requirement.\n */\nexport interface Reporter {\n onScenarioEnd?(result: ScenarioResult): void;\n onComplete(results: ScenarioResult[], durationMs: number): void;\n}\n\nexport interface ReporterOptions {\n cwd?: string;\n verbose?: boolean;\n}\n\n// --- ANSI colouring -------------------------------------------------------\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\n\nconst wrap = (open: number, close: number) => (s: string) =>\n useColor ? `\\x1b[${open}m${s}\\x1b[${close}m` : s;\n\nconst c = {\n green: wrap(32, 39),\n red: wrap(31, 39),\n yellow: wrap(33, 39),\n dim: wrap(2, 22),\n bold: wrap(1, 22),\n};\n\nconst STATUS_MARK: Record<StepResult[\"status\"], string> = {\n passed: c.green(\"✓\"),\n failed: c.red(\"✗\"),\n skipped: c.yellow(\"-\"),\n};\n\n/** ✓ / ✗ / - for a whole scenario (skipped = every step skipped). */\nfunction scenarioMark(result: ScenarioResult): string {\n if (result.status === \"failed\") return c.red(\"✗\");\n if (result.steps.every(s => s.status === \"skipped\")) return c.yellow(\"-\");\n return c.green(\"✓\");\n}\n\n/** Dot per scenario for the live heartbeat: `.` pass / `F` fail / `-` skip. */\nfunction scenarioDot(result: ScenarioResult): string {\n if (result.status === \"failed\") return c.red(\"F\");\n if (result.steps.every(s => s.status === \"skipped\")) return c.yellow(\"-\");\n return c.green(\".\");\n}\n\n/** Indent every non-empty line of a block by `pad` spaces. */\nfunction indent(text: string, pad: number): string {\n const prefix = \" \".repeat(pad);\n return text\n .split(\"\\n\")\n .map(line => (line ? prefix + line : line))\n .join(\"\\n\");\n}\n\n/**\n * The error, trimmed to user frames: `Name: message` followed by only the\n * caller's own stack frames (library/engine and `node_modules` frames removed),\n * source-mapped by Bun to the original `.ts`. Falls back to just the message\n * when nothing user-owned is left (e.g. an undefined-step error).\n */\nfunction renderError(error: Error, cwd: string): string {\n const header = `${error.name}: ${error.message}`;\n const frames = userFrames(error.stack).map(\n f => ` at ${relativeFrame(f, cwd)}`\n );\n return frames.length ? `${header}\\n${frames.join(\"\\n\")}` : header;\n}\n\n/**\n * The detail block shown beneath a failing step: the `.feature` line, the step\n * definition location, and the trimmed error — the two coordinates that make a\n * failure easy to chase (where in the feature, which step definition).\n */\nfunction failureDetail(\n stepResult: StepResult,\n result: ScenarioResult,\n cwd: string\n): string {\n const lines = [\n `feature: ${relative(cwd, result.scenario.file)}:${stepResult.step.line}`,\n ];\n if (stepResult.source) {\n lines.push(`defined: ${relativeLocation(stepResult.source, cwd)}`);\n }\n if (stepResult.error) lines.push(renderError(stepResult.error, cwd));\n return indent(c.red(lines.join(\"\\n\")), 6);\n}\n\n/**\n * One scenario as a Cucumber-style block: a marked header with its `.feature`\n * location, then each step with its mark (and, in `verbose`, the step\n * definition location as a trailing comment). A failing step is followed by its\n * failure detail; a scenario-level error (a failing hook, no step to blame) is\n * appended at the end.\n */\nfunction renderScenario(\n result: ScenarioResult,\n cwd: string,\n opts: { stepSource: boolean }\n): string {\n const label = result.scenario.outline\n ? `${result.scenario.outline.name} › ${result.scenario.name}`\n : result.scenario.name;\n const lines: string[] = [`${scenarioMark(result)} ${c.bold(label)}`];\n\n const loc = result.scenario.line\n ? `${relative(cwd, result.scenario.file)}:${result.scenario.line}`\n : relative(cwd, result.scenario.file);\n lines.push(indent(c.dim(loc), 4));\n lines.push(\"\");\n\n for (const step of result.scenario.steps) {\n const sr = result.steps.find(s => s.step === step);\n const status = sr?.status ?? \"skipped\";\n const comment =\n opts.stepSource && sr?.source\n ? c.dim(` # ${relativeLocation(sr.source, cwd)}`)\n : \"\";\n lines.push(\n ` ${STATUS_MARK[status]} ${c.dim(step.effectiveKeyword)} ${step.text}${comment}`\n );\n if (sr?.status === \"failed\") lines.push(failureDetail(sr, result, cwd));\n }\n\n // A hook failure has no failing step; surface its error at scenario level.\n const stepFailed = result.steps.some(s => s.status === \"failed\");\n if (result.error && !stepFailed) {\n lines.push(indent(c.red(renderError(result.error, cwd)), 4));\n }\n\n return lines.join(\"\\n\");\n}\n\n// --- Summary --------------------------------------------------------------\ninterface Totals {\n scenarios: { passed: number; failed: number; skipped: number };\n steps: { passed: number; failed: number; skipped: number };\n}\n\nfunction tally(results: ScenarioResult[]): Totals {\n const totals: Totals = {\n scenarios: { passed: 0, failed: 0, skipped: 0 },\n steps: { passed: 0, failed: 0, skipped: 0 },\n };\n for (const result of results) {\n if (result.status === \"failed\") totals.scenarios.failed++;\n else if (result.steps.every(s => s.status === \"skipped\"))\n totals.scenarios.skipped++;\n else totals.scenarios.passed++;\n for (const step of result.steps) totals.steps[step.status]++;\n }\n return totals;\n}\n\nfunction renderSummary(results: ScenarioResult[], durationMs: number): string {\n const t = tally(results);\n const scenarioTotal =\n t.scenarios.passed + t.scenarios.failed + t.scenarios.skipped;\n const stepTotal = t.steps.passed + t.steps.failed + t.steps.skipped;\n\n const part = (n: number, label: string, color: (s: string) => string) =>\n n > 0 ? color(`${n} ${label}`) : null;\n\n const line = (\n total: number,\n noun: string,\n counts: { passed: number; failed: number; skipped: number }\n ) => {\n const parts = [\n part(counts.passed, \"passed\", c.green),\n part(counts.failed, \"failed\", c.red),\n part(counts.skipped, \"skipped\", c.yellow),\n ].filter((x): x is string => x !== null);\n return `${total} ${noun}${total === 1 ? \"\" : \"s\"} (${parts.join(\", \")})`;\n };\n\n return [\n line(scenarioTotal, \"scenario\", t.scenarios),\n line(stepTotal, \"step\", t.steps),\n c.dim(`${(durationMs / 1000).toFixed(2)}s`),\n ].join(\"\\n\");\n}\n\nfunction write(text: string): void {\n process.stdout.write(text);\n}\n\n/** Feature-grouped tree of every scenario (used by `--verbose`). */\nfunction renderFullTree(results: ScenarioResult[], cwd: string): string {\n const groups = new Map<string, ScenarioResult[]>();\n for (const r of results) {\n const bucket = groups.get(r.scenario.file) ?? [];\n bucket.push(r);\n groups.set(r.scenario.file, bucket);\n }\n const out: string[] = [];\n for (const [file, group] of groups) {\n out.push(c.bold(`Feature: ${relative(cwd, file)}`), \"\");\n for (const r of group)\n out.push(indent(renderScenario(r, cwd, { stepSource: true }), 2), \"\");\n }\n return out.join(\"\\n\");\n}\n\n/** The failing scenarios only (used by the default, non-verbose output). */\nfunction renderFailures(results: ScenarioResult[], cwd: string): string {\n const failed = results.filter(r => r.status === \"failed\");\n if (!failed.length) return \"\";\n return (\n failed\n .map(r => renderScenario(r, cwd, { stepSource: false }))\n .join(\"\\n\\n\") + \"\\n\\n\"\n );\n}\n\n/**\n * Default reporter. Non-verbose: a dot per scenario as a heartbeat, then the\n * failing scenarios in Cucumber-style detail, then the summary. Verbose: the\n * full feature → scenario → step tree instead of just failures.\n */\nexport function prettyReporter(opts: ReporterOptions = {}): Reporter {\n const cwd = opts.cwd ?? process.cwd();\n const verbose = opts.verbose ?? false;\n return {\n onScenarioEnd(result) {\n if (!verbose) write(scenarioDot(result));\n },\n onComplete(results, durationMs) {\n const body = verbose\n ? `\\n${renderFullTree(results, cwd)}\\n`\n : `\\n\\n${renderFailures(results, cwd)}`;\n write(`${body}${renderSummary(results, durationMs)}\\n`);\n },\n };\n}\n\n/**\n * Compact reporter: a dot per scenario, then failures in detail and the\n * summary. Always minimal — `verbose` is accepted for interface parity but does\n * not expand the output (use `pretty --verbose` for the full tree).\n */\nexport function progressReporter(opts: ReporterOptions = {}): Reporter {\n const cwd = opts.cwd ?? process.cwd();\n return {\n onScenarioEnd(result) {\n write(scenarioDot(result));\n },\n onComplete(results, durationMs) {\n write(\n `\\n\\n${renderFailures(results, cwd)}${renderSummary(results, durationMs)}\\n`\n );\n },\n };\n}\n\nexport function makeReporter(\n name: \"pretty\" | \"progress\",\n opts: ReporterOptions = {}\n): Reporter {\n return name === \"progress\" ? progressReporter(opts) : prettyReporter(opts);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { ParsedScenario } from \"../analyzer/types\";\nimport { parseFeatureFiles } from \"../analyzer/gherkinParser\";\nimport { globFiles } from \"../globFiles\";\nimport { BasicWorld, MergeableWorld } from \"../world\";\nimport {\n compileRegistry,\n CompiledStep,\n runScenario,\n ScenarioResult,\n} from \"./engine\";\nimport { globalHookRegistry, runHooks, runHooksParallel } from \"./hooks\";\nimport { globalRegistry } from \"./registry\";\nimport { selectScenarios } from \"./filter\";\nimport { makeReporter, Reporter } from \"./reporters\";\nimport { ResolvedConfig } from \"./config\";\n\ntype WorldFactory = () => MergeableWorld<any, any, any>;\n\n/**\n * Import every step-definition module so its `.step(...)` calls self-register\n * into the shared `globalRegistry`. Imported by file URL so Bun transpiles the\n * TypeScript natively.\n */\nasync function importSteps(files: string[]): Promise<void> {\n for (const file of files) {\n await import(pathToFileURL(file).href);\n }\n}\n\n/** Load the configured world factory, or default to a fresh `BasicWorld`. */\nasync function loadWorldFactory(\n world: string | undefined,\n cwd: string\n): Promise<WorldFactory> {\n if (!world) return () => new BasicWorld();\n const resolved = path.resolve(cwd, world);\n const mod = await import(pathToFileURL(resolved).href);\n const factory = mod.default ?? mod;\n if (typeof factory !== \"function\") {\n throw new Error(\n `World module ${world} must default-export a factory function () => world`\n );\n }\n return factory as WorldFactory;\n}\n\n/** A scenario carrying `@skip` never runs: report it with all steps skipped. */\nfunction skippedResult(scenario: ParsedScenario): ScenarioResult {\n return {\n scenario,\n status: \"passed\",\n steps: scenario.steps.map(step => ({ step, status: \"skipped\" as const })),\n };\n}\n\n/**\n * Run `items` through `worker`, at most `limit` in flight. Results come back in\n * input order even though completion order is not deterministic. A minimal\n * dependency-free pool — the whole point of the single-process model.\n */\nasync function runPool<T, R>(\n items: T[],\n limit: number,\n worker: (item: T, index: number) => Promise<R>\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n let cursor = 0;\n const runNext = async (): Promise<void> => {\n while (cursor < items.length) {\n const index = cursor++;\n results[index] = await worker(items[index], index);\n }\n };\n const workers = Array.from(\n { length: Math.min(Math.max(1, limit), items.length) },\n runNext\n );\n await Promise.all(workers);\n return results;\n}\n\nexport interface RunResult {\n results: ScenarioResult[];\n passed: boolean;\n durationMs: number;\n}\n\n/**\n * Execute a whole run end to end: discover and import steps, load the world,\n * parse and select scenarios, then run them concurrently against a\n * compiled-once step table with global/feature hooks around the batch. Never\n * throws for test failures — inspect `RunResult.passed`.\n */\nexport async function run(\n config: ResolvedConfig,\n reporter: Reporter = makeReporter(config.reporter, {\n cwd: config.cwd,\n verbose: config.verbose,\n })\n): Promise<RunResult> {\n const start =\n typeof performance !== \"undefined\" ? performance.now() : Date.now();\n\n const [featureFiles, stepFiles] = await Promise.all([\n globFiles(config.features, config.cwd),\n globFiles(config.steps, config.cwd),\n ]);\n\n await importSteps(stepFiles);\n const makeWorld = await loadWorldFactory(config.world, config.cwd);\n\n const compiled: CompiledStep[] = compileRegistry(globalRegistry);\n const allScenarios = parseFeatureFiles(featureFiles);\n const selected = selectScenarios(allScenarios, {\n name: config.name,\n tags: config.tags,\n });\n\n // Global `beforeAll` hooks run once, in parallel, before any scenario starts;\n // feature before/after bracket the whole batch inside them. (Hooks aren't\n // file-scoped in the registry, so per-file bracketing would be meaningless\n // under concurrent execution.)\n await runHooksParallel(\"global\", \"before\", globalHookRegistry);\n await runHooks(\"feature\", \"before\", globalHookRegistry);\n\n const results = await runPool(\n selected,\n config.concurrency,\n async scenario => {\n const result = scenario.tags.includes(\"@skip\")\n ? skippedResult(scenario)\n : await runScenario(scenario, compiled, makeWorld, globalHookRegistry);\n reporter.onScenarioEnd?.(result);\n return result;\n }\n );\n\n await runHooks(\"feature\", \"after\", globalHookRegistry);\n // Global `afterAll` hooks run once, in parallel, after every scenario is done.\n await runHooksParallel(\"global\", \"after\", globalHookRegistry);\n\n const durationMs =\n (typeof performance !== \"undefined\" ? performance.now() : Date.now()) -\n start;\n reporter.onComplete(results, durationMs);\n\n return {\n results,\n passed: results.every(r => r.status !== \"failed\"),\n durationMs,\n };\n}\n","import * as readline from \"node:readline\";\n\n/**\n * A hand-rolled, dependency-free typeahead prompt for interactive mode. It owns\n * the terminal's raw-mode input and renders a block pinned to the bottom of the\n * screen: a scrollable list of suggestions above a `> query` input line. Run\n * output is meant to scroll *above* this block — {@link Prompt.printAbove} erases\n * the block, lets a caller write, then redraws it lower down.\n *\n * The prompt is pure view + input: it filters/ranks {@link Suggestion}s by the\n * typed query and reports intent through callbacks ({@link PromptHandlers}), but\n * holds no run/watch logic. The orchestrator wires those callbacks.\n */\nexport interface Suggestion {\n /** Human label shown after the badge, e.g. a scenario name. */\n label: string;\n /** Short kind marker shown before the label, e.g. `#tag` / `feature`. */\n badge: string;\n /** Text the query is matched against (case-insensitively). */\n search: string;\n /** Opaque payload handed back to {@link PromptHandlers.onSubmit}. */\n value: unknown;\n}\n\nexport interface PromptHandlers {\n /** Enter: `value` is the highlighted suggestion, or `null` when none matches. */\n onSubmit(value: unknown | null, query: string): void;\n /** The query text changed (insert/delete) — used to suspend auto-runs. */\n onEdit(query: string): void;\n /** Escape pressed. */\n onEscape(): void;\n /** Ctrl-C / Ctrl-D — the caller should tear down and exit. */\n onQuit(): void;\n}\n\nexport interface PromptOptions {\n handlers: PromptHandlers;\n /** Input prefix. Default `\"› \"`. */\n prefix?: string;\n /** Max suggestion rows shown at once. Default `10`. */\n maxVisible?: number;\n /** Initial query text. */\n initialQuery?: string;\n}\n\n// --- ANSI ------------------------------------------------------------------\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\nconst wrap = (open: number, close: number) => (s: string) =>\n useColor ? `\\x1b[${open}m${s}\\x1b[${close}m` : s;\nconst color = {\n green: wrap(32, 39),\n cyan: wrap(36, 39),\n dim: wrap(2, 22),\n bold: wrap(1, 22),\n inverse: wrap(7, 27),\n};\n\n/** Ranked match: lower rank sorts first; `-1` means \"no match\" (excluded). */\nfunction rank(search: string, query: string): number {\n if (!query) return 0;\n const idx = search.indexOf(query);\n if (idx === -1) return -1;\n if (idx === 0) return 0; // prefix\n // word-boundary (space, `:`, `›`, `@`) scores above a bare substring.\n return /[\\s:›@/]/.test(search[idx - 1]) ? 1 : 2;\n}\n\nexport class Prompt {\n private readonly handlers: PromptHandlers;\n private readonly prefix: string;\n private readonly maxVisible: number;\n\n private all: Suggestion[] = [];\n private matches: Suggestion[] = [];\n private query: string;\n private cursor: number; // caret index within `query`\n private selected = 0; // index into `matches`\n private window = 0; // first visible match index\n\n /** Optional dim status line shown just above the input (set by the caller). */\n status = \"\";\n\n /** Lines the pinned block currently occupies, so a redraw can erase them. */\n private rendered = 0;\n private started = false;\n /** While true the block is hidden so a run's output can own the screen. */\n private suspended = false;\n private keyListener?: (str: string, key: readline.Key) => void;\n\n constructor(options: PromptOptions) {\n this.handlers = options.handlers;\n this.prefix = options.prefix ?? \"› \";\n this.maxVisible = options.maxVisible ?? 10;\n this.query = options.initialQuery ?? \"\";\n this.cursor = this.query.length;\n }\n\n /** Replace the suggestion pool (e.g. after the feature cache rebuilds). */\n setSuggestions(suggestions: Suggestion[]): void {\n this.all = suggestions;\n this.refilter();\n if (this.started) this.render();\n }\n\n get value(): string {\n return this.query;\n }\n\n /** Enter raw mode, attach the keypress listener, and draw the block. */\n start(): void {\n if (this.started) return;\n this.started = true;\n readline.emitKeypressEvents(process.stdin);\n if (process.stdin.isTTY) process.stdin.setRawMode(true);\n this.keyListener = (str, key) => this.onKey(str, key ?? {});\n process.stdin.on(\"keypress\", this.keyListener);\n process.stdin.resume();\n this.render();\n }\n\n /** Erase the block, restore cooked mode, and detach the listener. */\n stop(): void {\n if (!this.started) return;\n this.started = false;\n this.erase();\n write(\"\\x1b[?25h\"); // ensure the cursor is visible again\n if (this.keyListener) process.stdin.off(\"keypress\", this.keyListener);\n if (process.stdin.isTTY) process.stdin.setRawMode(false);\n process.stdin.pause();\n }\n\n /**\n * Erase the pinned block and hide it for the duration of an (async) run, so\n * everything written to stdout in the meantime scrolls where the prompt was.\n * Keypresses still update state but don't repaint until {@link endOutput}.\n */\n beginOutput(): void {\n if (!this.started) return;\n this.erase();\n this.suspended = true;\n }\n\n /** Redraw the pinned block below whatever output {@link beginOutput} let through. */\n endOutput(): void {\n if (!this.started) return;\n this.suspended = false;\n this.render();\n }\n\n /** Force a redraw (after mutating `status`, say). No-op while suspended. */\n redraw(): void {\n if (this.started && !this.suspended) this.render();\n }\n\n // --- input ---------------------------------------------------------------\n private onKey(str: string, key: readline.Key): void {\n if (key.ctrl && (key.name === \"c\" || key.name === \"d\")) {\n this.handlers.onQuit();\n return;\n }\n switch (key.name) {\n case \"return\":\n case \"enter\": {\n const value = this.matches[this.selected]?.value ?? null;\n this.handlers.onSubmit(value, this.query);\n return;\n }\n case \"escape\":\n this.handlers.onEscape();\n return;\n case \"up\":\n this.move(-1);\n return;\n case \"down\":\n this.move(1);\n return;\n case \"left\":\n this.cursor = Math.max(0, this.cursor - 1);\n this.render();\n return;\n case \"right\":\n this.cursor = Math.min(this.query.length, this.cursor + 1);\n this.render();\n return;\n case \"home\":\n this.cursor = 0;\n this.render();\n return;\n case \"end\":\n this.cursor = this.query.length;\n this.render();\n return;\n case \"backspace\":\n this.deleteBefore();\n return;\n case \"delete\":\n this.deleteAfter();\n return;\n }\n // Any single printable character (space included) is inserted.\n if (str && str.length === 1 && str >= \" \" && !key.ctrl && !key.meta) {\n this.insert(str);\n }\n }\n\n private insert(ch: string): void {\n this.query =\n this.query.slice(0, this.cursor) + ch + this.query.slice(this.cursor);\n this.cursor += ch.length;\n this.afterEdit();\n }\n\n private deleteBefore(): void {\n if (this.cursor === 0) return;\n this.query =\n this.query.slice(0, this.cursor - 1) + this.query.slice(this.cursor);\n this.cursor--;\n this.afterEdit();\n }\n\n private deleteAfter(): void {\n if (this.cursor >= this.query.length) return;\n this.query =\n this.query.slice(0, this.cursor) + this.query.slice(this.cursor + 1);\n this.afterEdit();\n }\n\n private afterEdit(): void {\n this.refilter();\n this.render();\n this.handlers.onEdit(this.query);\n }\n\n private move(delta: number): void {\n if (this.matches.length === 0) return;\n this.selected = Math.min(\n this.matches.length - 1,\n Math.max(0, this.selected + delta)\n );\n this.reWindow();\n this.render();\n }\n\n private refilter(): void {\n const q = this.query.trim().toLowerCase();\n this.matches = this.all\n .map((s, index) => ({ s, index, r: rank(s.search, q) }))\n .filter(m => m.r !== -1)\n .sort((a, b) => a.r - b.r || a.index - b.index)\n .map(m => m.s);\n this.selected = 0;\n this.window = 0;\n }\n\n private reWindow(): void {\n if (this.selected < this.window) this.window = this.selected;\n else if (this.selected >= this.window + this.maxVisible)\n this.window = this.selected - this.maxVisible + 1;\n }\n\n // --- rendering -----------------------------------------------------------\n /** Build the block's lines, top (suggestions) to bottom (input). */\n private buildLines(): string[] {\n const lines: string[] = [];\n const total = this.matches.length;\n\n if (this.query.trim() && total === 0) {\n lines.push(color.dim(\" no matching tag, feature, or scenario\"));\n }\n\n const end = Math.min(this.window + this.maxVisible, total);\n for (let i = this.window; i < end; i++) {\n const s = this.matches[i];\n const active = i === this.selected;\n const badge = color.cyan(s.badge.padEnd(9));\n const row = `${badge} ${s.label}`;\n lines.push(active ? color.inverse(`❯ ${row}`) : ` ${row}`);\n }\n if (total > end) {\n lines.push(color.dim(` …and ${total - end} more`));\n }\n\n if (this.status) lines.push(color.dim(this.status));\n lines.push(`${color.bold(this.prefix)}${this.query}`);\n return lines;\n }\n\n private render(): void {\n if (this.suspended) return; // a run owns the screen; don't repaint over it\n write(\"\\x1b[?25l\"); // hide caret while we repaint\n this.moveToBlockStart();\n write(\"\\x1b[0J\"); // clear from here to end of screen\n const lines = this.buildLines();\n write(lines.join(\"\\r\\n\"));\n this.rendered = lines.length;\n // Park the caret on the input line at the right column.\n write(`\\r\\x1b[${stringWidth(this.prefix) + this.cursor}C`);\n write(\"\\x1b[?25h\");\n }\n\n /** Erase the block and leave the caret at the block's top-left. */\n private erase(): void {\n this.moveToBlockStart();\n write(\"\\x1b[0J\");\n this.rendered = 0;\n }\n\n /** Move the caret to column 0 of the block's first line. */\n private moveToBlockStart(): void {\n if (this.rendered > 1) write(`\\x1b[${this.rendered - 1}A`);\n write(\"\\r\");\n }\n}\n\n/** Visible width, ignoring the ANSI escapes our color helpers may inject. */\nfunction stringWidth(s: string): number {\n // eslint-disable-next-line no-control-regex\n return s.replace(/\\x1b\\[[0-9;]*m/g, \"\").length;\n}\n\nfunction write(s: string): void {\n process.stdout.write(s);\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n/** Glob metacharacters — the same set {@link globFiles} treats as \"magic\". */\nconst MAGIC = /[*?[\\]{}!()]/;\n\n/** File extensions worth reacting to: features and step/world modules. */\nconst WATCHED_EXT = /\\.(feature|ts|mts|js|mjs|cts|cjs)$/;\n\nexport interface Watcher {\n /** Stop watching and release every underlying `fs.watch` handle. */\n close(): void;\n}\n\n/**\n * Watch the directories implied by feature/step globs and invoke `onChange`\n * (debounced, coalesced) whenever a relevant file changes. Roots are the literal\n * directory prefixes of each glob — e.g. `features/**\\/*.feature` watches\n * `features/` recursively — deduped so nested roots aren't watched twice.\n *\n * Recursive watching is supported on macOS and Windows and on modern Linux\n * (Node ≥ 20 / Bun); on older Linux only the top level of each root is seen.\n */\nexport function watchFeatures(\n globs: string[],\n cwd: string,\n onChange: () => void,\n debounceMs = 120\n): Watcher {\n const roots = watchRoots(globs, cwd);\n const watchers: fs.FSWatcher[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const schedule = (filename: string | null) => {\n // `fs.watch` may report a null filename; when we do get one, ignore churn\n // from unrelated files (editor swap files, `.git`, build output).\n if (filename && !WATCHED_EXT.test(filename)) return;\n if (timer) clearTimeout(timer);\n timer = setTimeout(onChange, debounceMs);\n };\n\n for (const root of roots) {\n try {\n const w = fs.watch(root, { recursive: true }, (_event, filename) =>\n schedule(filename)\n );\n w.on(\"error\", () => {}); // a removed/renamed root shouldn't crash the loop\n watchers.push(w);\n } catch {\n // Root doesn't exist yet (or can't be watched) — skip it silently.\n }\n }\n\n return {\n close() {\n if (timer) clearTimeout(timer);\n for (const w of watchers) w.close();\n },\n };\n}\n\n/**\n * The set of directories to watch: each glob's literal prefix (the path up to\n * its first magic character), resolved against `cwd`, deduped, with any root\n * that nests inside another dropped. Falls back to `cwd` when nothing resolves.\n */\nexport function watchRoots(globs: string[], cwd: string): string[] {\n const dirs = new Set<string>();\n for (const glob of globs) {\n dirs.add(path.resolve(cwd, literalPrefix(glob)));\n }\n const roots = [...dirs].sort();\n // Drop any root contained in an earlier (shorter) one, so recursive watches\n // don't overlap.\n const pruned = roots.filter(\n (r, i) => !roots.some((other, j) => j < i && isInside(r, other))\n );\n return pruned.length ? pruned : [cwd];\n}\n\n/** The directory portion of a glob before its first magic segment. */\nfunction literalPrefix(glob: string): string {\n const segments = glob.split(\"/\");\n const literal: string[] = [];\n for (const seg of segments) {\n if (MAGIC.test(seg)) break;\n literal.push(seg);\n }\n const joined = literal.join(\"/\");\n // A bare `*.feature` has no literal prefix → watch cwd (\".\").\n if (!joined) return \".\";\n // If the whole pattern was literal it points at a file; watch its directory.\n return MAGIC.test(glob) ? joined : path.dirname(joined);\n}\n\n/** True when `child` is `parent` itself or nested beneath it. */\nfunction isInside(child: string, parent: string): boolean {\n if (child === parent) return true;\n const rel = path.relative(parent, child);\n return !!rel && !rel.startsWith(\"..\") && !path.isAbsolute(rel);\n}\n","import { spawn } from \"node:child_process\";\nimport * as path from \"node:path\";\nimport { ParsedScenario } from \"../analyzer/types\";\nimport { ParsedFeature, parseFeatureCatalog } from \"../analyzer/gherkinParser\";\nimport { globFiles } from \"../globFiles\";\nimport { ResolvedConfig } from \"./config\";\nimport { Prompt, Suggestion } from \"./prompt\";\nimport { watchFeatures, Watcher } from \"./watcher\";\n\n/**\n * A population the user can pick and run: a whole tag, a whole feature file, or\n * a single scenario. Resolved against the freshly-parsed features on every run,\n * so it survives edits that shift line numbers.\n */\ntype Choice =\n | { kind: \"tag\"; tag: string }\n | { kind: \"feature\"; file: string; name: string }\n | { kind: \"scenario\"; file: string; name: string; line?: number };\n\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\nconst bold = (s: string) => (useColor ? `\\x1b[1m${s}\\x1b[22m` : s);\nconst dim = (s: string) => (useColor ? `\\x1b[2m${s}\\x1b[22m` : s);\nconst red = (s: string) => (useColor ? `\\x1b[31m${s}\\x1b[39m` : s);\nconst yellow = (s: string) => (useColor ? `\\x1b[33m${s}\\x1b[39m` : s);\n\n/**\n * Entry point for `step-forge -i`. Brings up the always-live typeahead prompt,\n * watches the configured feature/step directories, and re-runs the armed\n * population on every relevant file change. Requires a TTY.\n */\nexport async function runInteractive(config: ResolvedConfig): Promise<void> {\n if (!process.stdin.isTTY) {\n process.stderr.write(\n \"Interactive mode (-i) requires a TTY; stdin is not a terminal.\\n\"\n );\n process.exitCode = 1;\n return;\n }\n await new InteractiveSession(config).start();\n}\n\nclass InteractiveSession {\n private readonly config: ResolvedConfig;\n private readonly prompt: Prompt;\n private watcher?: Watcher;\n private catalog: ParsedFeature[] = [];\n\n // State machine: `armed` is the committed population; `dirty` means the query\n // was edited since the last commit, which suspends file-change re-runs.\n private armed: Choice | null = null;\n private dirty = false;\n private running = false;\n private rerunQueued = false;\n /** Increments per run so back-to-back identical output is still distinguishable. */\n private runCount = 0;\n\n private done!: () => void;\n\n constructor(config: ResolvedConfig) {\n this.config = config;\n this.prompt = new Prompt({\n initialQuery: config.tags ?? config.name ?? \"\",\n handlers: {\n onSubmit: value => this.onSubmit(value),\n onEdit: () => this.onEdit(),\n onEscape: () => this.onEscape(),\n onQuit: () => this.onQuit(),\n },\n });\n }\n\n async start(): Promise<void> {\n await this.rebuildCatalog();\n this.prompt.status = this.status();\n this.prompt.start();\n this.watcher = watchFeatures(\n [...this.config.features, ...this.config.steps],\n this.config.cwd,\n () => void this.onFsChange()\n );\n await new Promise<void>(resolve => {\n this.done = resolve;\n });\n }\n\n // --- prompt events -------------------------------------------------------\n private onSubmit(value: unknown | null): void {\n if (!value) return; // nothing highlighted (empty query / no matches)\n this.armed = value as Choice;\n this.dirty = false;\n this.prompt.status = this.status();\n this.triggerRun();\n }\n\n private onEdit(): void {\n // Editing the query suspends auto-runs until the next Enter re-commits.\n if (this.armed) this.dirty = true;\n this.prompt.status = this.status();\n this.prompt.redraw();\n }\n\n private onEscape(): void {\n if (!this.armed) return;\n this.armed = null;\n this.dirty = false;\n this.prompt.status = this.status();\n this.prompt.redraw();\n }\n\n private onQuit(): void {\n this.watcher?.close();\n this.prompt.stop();\n process.stdout.write(\"\\n\");\n process.exitCode = 0;\n this.done?.();\n }\n\n // --- filesystem watch ----------------------------------------------------\n private async onFsChange(): Promise<void> {\n await this.rebuildCatalog();\n if (this.armed && !this.dirty) this.triggerRun();\n }\n\n private async rebuildCatalog(): Promise<void> {\n try {\n const featureFiles = await globFiles(\n this.config.features,\n this.config.cwd\n );\n this.catalog = parseFeatureCatalog(featureFiles);\n } catch {\n // A half-written feature mid-save may fail to parse; keep the old cache.\n }\n this.prompt.setSuggestions(buildSuggestions(this.catalog));\n }\n\n // --- run cycle -----------------------------------------------------------\n private triggerRun(): void {\n if (!this.armed) return;\n if (this.running) {\n this.rerunQueued = true; // coalesce: run once more when the current ends\n return;\n }\n this.running = true;\n this.prompt.beginOutput();\n void this.runLoop();\n }\n\n private async runLoop(): Promise<void> {\n try {\n do {\n this.rerunQueued = false;\n if (this.armed) await this.executeOnce(this.armed);\n } while (this.rerunQueued && this.armed && !this.dirty);\n } catch (err) {\n process.stdout.write(\n red(`\\n run failed: ${err instanceof Error ? err.message : err}\\n`)\n );\n } finally {\n this.running = false;\n this.prompt.status = this.status();\n this.prompt.endOutput(); // redraws the prompt below the run's output\n }\n }\n\n /**\n * One run of `choice`: resolve its scenarios against the current parse, then\n * shell out to a **fresh** `step-forge` process scoped to just that\n * population. A child process is used deliberately — Bun caches ES modules for\n * the life of a process and ignores query-string cache-busting, so re-running\n * in-process would never pick up edited step code. A new process re-reads\n * every step/feature file, which is exactly what a watch loop needs.\n */\n private async executeOnce(choice: Choice): Promise<void> {\n const selected = resolveScenarios(choice, this.scenarios());\n\n const count = `${selected.length} scenario${selected.length === 1 ? \"\" : \"s\"}`;\n process.stdout.write(\n `\\n${bold(`▶ ${choiceLabel(choice)}`)} ${dim(\n `(${count} · run #${++this.runCount} · ${clock()})`\n )}\\n\\n`\n );\n\n if (selected.length === 0) {\n process.stdout.write(yellow(\" no scenarios match this selection\\n\"));\n return;\n }\n\n // A single scenario is analyzed (dependency/undefined/ambiguous checks) and\n // run verbose; a broader population uses the configured reporter.\n const single = selected.length === 1;\n if (single) await this.analyzeScenario(selected[0]);\n\n await this.spawnRun(runArgs(choice, selected[0], single, this.config));\n }\n\n /** Every scenario across the current catalog, flattened. */\n private scenarios(): ParsedScenario[] {\n return this.catalog.flatMap(f => f.scenarios);\n }\n\n /**\n * Run `step-forge` as a child process with `args`, streaming its output to the\n * terminal (where the erased prompt was). Re-invokes the very CLI that's\n * running us (`process.execPath` + `argv[1]`), so it works identically from\n * the source tree and the built bin. Never rejects — a spawn error is reported\n * and swallowed so the watch loop survives.\n */\n private spawnRun(args: string[]): Promise<void> {\n return new Promise(resolve => {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd: this.config.cwd,\n // Own stdin ourselves (raw-mode prompt); let the child inherit our\n // stdout/stderr so its reporter output lands above the prompt live.\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n });\n child.on(\"error\", err => {\n process.stdout.write(red(` could not start runner: ${err.message}\\n`));\n resolve();\n });\n child.on(\"close\", () => resolve());\n });\n }\n\n /**\n * Run the static analyzer over a single scenario and print any dependency /\n * undefined / ambiguous diagnostics. The analyzer needs the optional\n * `typescript` peer for AST extraction; if it's absent we note that and skip,\n * never failing the run.\n */\n private async analyzeScenario(scenario: ParsedScenario): Promise<void> {\n let analyzer: typeof import(\"../analyzer/index\");\n try {\n analyzer = await import(\"../analyzer/index\");\n } catch {\n process.stdout.write(\n dim(\" analysis skipped: install `typescript` to enable it\\n\\n\")\n );\n return;\n }\n try {\n const stepFiles = await globFiles(this.config.steps, this.config.cwd);\n const defs = analyzer.extractStepDefinitions(stepFiles);\n const matched = analyzer.matchScenarioSteps(scenario, defs);\n const diagnostics = analyzer.defaultRules.flatMap(rule =>\n rule.check(scenario, matched)\n );\n printDiagnostics(diagnostics, this.config.cwd);\n } catch (err) {\n process.stdout.write(\n dim(\n ` analysis unavailable: ${err instanceof Error ? err.message : err}\\n\\n`\n )\n );\n }\n }\n\n // --- status line ---------------------------------------------------------\n private status(): string {\n if (!this.armed) {\n return \" type to filter · ↑↓ move · enter run · ctrl-c quit\";\n }\n if (this.dirty) {\n return \" ⏸ suspended (query edited) · enter runs the selection · esc cancel\";\n }\n return ` ▶ watching ${choiceLabel(this.armed)} · save a file to re-run · enter forces · esc change · ctrl-c quit`;\n }\n}\n\n// --- choices ---------------------------------------------------------------\n/** Build the typeahead pool: every tag, feature, and scenario in the catalog. */\nfunction buildSuggestions(catalog: ParsedFeature[]): Suggestion[] {\n const suggestions: Suggestion[] = [];\n\n const tags = new Set<string>();\n for (const feature of catalog) {\n for (const scenario of feature.scenarios) {\n for (const tag of scenario.tags) tags.add(tag);\n }\n }\n for (const tag of [...tags].sort()) {\n suggestions.push({\n badge: \"#tag\",\n label: tag,\n search: tag.toLowerCase(),\n value: { kind: \"tag\", tag } satisfies Choice,\n });\n }\n\n for (const feature of catalog) {\n const featureLabel = feature.name || path.basename(feature.file);\n suggestions.push({\n badge: \"feature\",\n label: featureLabel,\n search: `${feature.name} ${feature.file}`.toLowerCase(),\n value: {\n kind: \"feature\",\n file: feature.file,\n name: feature.name,\n } satisfies Choice,\n });\n\n for (const scenario of feature.scenarios) {\n const scenarioName = scenario.outline\n ? `${scenario.outline.name} › ${scenario.name}`\n : scenario.name;\n suggestions.push({\n badge: \"scenario\",\n label: scenarioName,\n search: `${featureLabel} ${scenarioName}`.toLowerCase(),\n value: {\n kind: \"scenario\",\n file: scenario.file,\n name: scenario.name,\n line: scenario.line,\n } satisfies Choice,\n });\n }\n }\n\n return suggestions;\n}\n\n/** Resolve a choice to its scenarios against the current parse. */\nfunction resolveScenarios(\n choice: Choice,\n scenarios: ParsedScenario[]\n): ParsedScenario[] {\n switch (choice.kind) {\n case \"tag\":\n return scenarios.filter(s => s.tags.includes(choice.tag));\n case \"feature\":\n return scenarios.filter(s => s.file === choice.file);\n case \"scenario\":\n return scenarios.filter(\n s =>\n s.file === choice.file &&\n s.name === choice.name &&\n (choice.line === undefined || s.line === choice.line)\n );\n }\n}\n\nfunction choiceLabel(choice: Choice): string {\n switch (choice.kind) {\n case \"tag\":\n return choice.tag;\n case \"feature\":\n return choice.name || path.basename(choice.file);\n case \"scenario\":\n return choice.name;\n }\n}\n\n/**\n * The `step-forge` argv that reproduces this selection in a child process. The\n * base flags forward the resolved config (steps/world/concurrency) so the child\n * matches the parent's setup regardless of its own config file; the scope flags\n * narrow to the chosen population:\n * - tag → all configured features, filtered by `-t <tag>`\n * - feature → that single feature file\n * - scenario → that feature file, name-anchored with `-n \"/^…$/\"`\n * A single scenario runs verbose; a population uses the configured reporter.\n */\nfunction runArgs(\n choice: Choice,\n first: ParsedScenario,\n single: boolean,\n config: ResolvedConfig\n): string[] {\n const args: string[] = [];\n for (const glob of config.steps) args.push(\"-s\", glob);\n if (config.world) args.push(\"-w\", config.world);\n args.push(\"-c\", String(config.concurrency));\n\n switch (choice.kind) {\n case \"tag\":\n args.push(...config.features, \"-t\", choice.tag);\n break;\n case \"feature\":\n args.push(choice.file);\n break;\n case \"scenario\":\n args.push(choice.file, \"-n\", `/^${escapeRegExp(first.name)}$/`);\n break;\n }\n\n if (single) {\n args.push(\"-v\");\n } else {\n args.push(\"-r\", config.reporter);\n if (config.verbose) args.push(\"-v\");\n }\n return args;\n}\n\n/** Escape a scenario name for use inside an anchored `-n` regex. */\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Local wall-clock time as `HH:MM:SS`, so each run's header is dated. */\nfunction clock(): string {\n const d = new Date();\n return [d.getHours(), d.getMinutes(), d.getSeconds()]\n .map(n => String(n).padStart(2, \"0\"))\n .join(\":\");\n}\n\n// --- diagnostics -----------------------------------------------------------\nfunction printDiagnostics(\n diagnostics: import(\"../analyzer/types\").Diagnostic[],\n cwd: string\n): void {\n if (diagnostics.length === 0) return; // clean scenario: say nothing, let the run speak\n process.stdout.write(bold(\" analyzer:\\n\"));\n for (const d of diagnostics) {\n const mark =\n d.severity === \"error\"\n ? red(\"✗\")\n : d.severity === \"warning\"\n ? yellow(\"!\")\n : dim(\"i\");\n const loc = `${path.relative(cwd, d.file)}:${d.range.startLine}`;\n process.stdout.write(` ${mark} ${d.message} ${dim(`(${loc})`)}\\n`);\n }\n process.stdout.write(\"\\n\");\n}\n","#!/usr/bin/env bun\nimport { parseArgs } from \"node:util\";\nimport * as path from \"node:path\";\nimport { loadConfigFile, resolveConfig, RunnerOptions } from \"./config\";\nimport { run } from \"./runner\";\nimport { runInteractive } from \"./interactive\";\n\nconst HELP = `step-forge — native TypeScript runner for Gherkin step definitions\n\nUsage:\n step-forge [options] [feature globs...]\n\nOptions:\n -t, --tags <expr> Tag expression, e.g. \"@smoke and not @wip\"\n -n, --name <pattern> Only scenarios whose name matches (substring or /regex/)\n -s, --steps <glob> Step-definition module glob (repeatable)\n -w, --world <module> World factory module (default export () => world)\n -c, --concurrency <n> Max scenarios in flight (default: 1, i.e. serial)\n -r, --reporter <name> \"pretty\" (default) or \"progress\"\n -v, --verbose Report every scenario, not just failures\n -i, --interactive Interactive watch mode: pick a tag/feature/scenario\n and re-run it on every file change\n --config <path> Config file directory (default: cwd)\n -h, --help Show this help\n\nPositional arguments are feature globs and override the configured features.\n`;\n\n/** Parse argv into config overrides. Positional args become feature globs. */\nfunction parseCli(argv: string[]): {\n cwd: string;\n overrides: RunnerOptions;\n interactive: boolean;\n} {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n tags: { type: \"string\", short: \"t\" },\n name: { type: \"string\", short: \"n\" },\n steps: { type: \"string\", short: \"s\", multiple: true },\n world: { type: \"string\", short: \"w\" },\n concurrency: { type: \"string\", short: \"c\" },\n reporter: { type: \"string\", short: \"r\" },\n verbose: { type: \"boolean\", short: \"v\" },\n interactive: { type: \"boolean\", short: \"i\" },\n config: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\" },\n },\n });\n\n if (values.help) {\n process.stdout.write(HELP);\n process.exit(0);\n }\n\n const overrides: RunnerOptions = {};\n if (positionals.length) overrides.features = positionals;\n if (values.tags) overrides.tags = values.tags;\n if (values.name) overrides.name = values.name;\n if (values.steps) overrides.steps = values.steps;\n if (values.world) overrides.world = values.world;\n if (values.verbose) overrides.verbose = true;\n if (values.reporter) {\n if (values.reporter !== \"pretty\" && values.reporter !== \"progress\") {\n throw new Error(`Unknown reporter: ${values.reporter}`);\n }\n overrides.reporter = values.reporter;\n }\n if (values.concurrency !== undefined) {\n const n = Number(values.concurrency);\n if (!Number.isInteger(n) || n < 1) {\n throw new Error(`--concurrency must be a positive integer`);\n }\n overrides.concurrency = n;\n }\n\n const cwd = values.config\n ? path.resolve(process.cwd(), values.config)\n : process.cwd();\n return { cwd, overrides, interactive: values.interactive ?? false };\n}\n\nasync function main(): Promise<void> {\n const { cwd, overrides, interactive } = parseCli(process.argv.slice(2));\n const fileConfig = await loadConfigFile(cwd);\n const config = resolveConfig(cwd, fileConfig, overrides);\n if (interactive) {\n await runInteractive(config);\n return; // interactive mode manages its own lifecycle and exit code\n }\n const { passed } = await run(config);\n process.exitCode = passed ? 0 : 1;\n}\n\nmain().catch(err => {\n process.stderr.write(`${err instanceof Error ? err.stack : String(err)}\\n`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;;AAqDA,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;AACF;AAEA,SAAS,QAAW,OAAiC;CACnD,IAAI,UAAU,KAAA,GAAW,OAAO,CAAC;CACjC,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;AAEA,eAAe,OAAO,GAA6B;CACjD,IAAI;EACF,MAAM,OAAO,CAAC;EACd,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;AAOA,eAAsB,eAAe,KAAqC;CACxE,KAAK,MAAM,YAAY,kBAAkB;EACvC,MAAM,YAAY,KAAK,KAAK,KAAK,QAAQ;EACzC,IAAI,CAAE,MAAM,OAAO,SAAS,GAAI;EAChC,MAAM,MAAM,MAAM,OAAO,cAAc,SAAS,CAAC,CAAC;EAClD,OAAQ,IAAI,WAAW;CACzB;CACA,OAAO,CAAC;AACV;;;;;;AAOA,SAAgB,cACd,KACA,MACA,KACgB;CAChB,MAAM,QAAuC,QAC3C,IAAI,QAAQ,KAAK;CAEnB,MAAM,WAAW,QAAQ,KAAK,UAAU,CAAC;CACzC,MAAM,QAAQ,QAAQ,KAAK,OAAO,CAAC;CAEnC,OAAO;EACL;EACA,UAAU,SAAS,SAAS,WAAW,CAAC,gBAAgB;EACxD,OAAO,MAAM,SAAS,QAAQ,CAAC,aAAa;EAC5C,OAAO,KAAK,OAAO;EACnB,aAAa,KAAK,aAAa,KAAK;EACpC,UAAU,KAAK,UAAU,KAAK;EAC9B,SAAS,KAAK,SAAS,KAAK;EAC5B,MAAM,KAAK,MAAM;EACjB,MAAM,KAAK,MAAM;CACnB;AACF;;;;AC3GA,SAAS,SAAS,MA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AM,IAAI,MAAM,qBAAqB,OAAO,UAAU;EAExD,UAAU,WAAW,OAAO;CAC9B;CACA,IAAI,OAAO,gBAAgB,KAAA,GAAW;EACpC,MAAM,IAAI,OAAO,OAAO,WAAW;EACnC,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,GAC9B,MAAM,IAAI,MAAM,0CAA0C;EAE5D,UAAU,cAAc;CAC1B;CAKA,OAAO;EAAE,KAHG,OAAO,SACf,KAAK,QAAQ,QAAQ,IAAI,GAAG,OAAO,MAAM,IACzC,QAAQ,IAAI;EACF;EAAW,aAAa,OAAO,eAAe;CAAM;AACpE;AAEA,eAAe,OAAsB;CACnC,MAAM,EAAE,KAAK,WAAW,gBAAgB,SAAS,QAAQ,KAAK,MAAM,CAAC,CAAC;CAEtE,MAAM,SAAS,cAAc,KAAK,MADT,eAAe,GAAG,GACG,SAAS;CACvD,IAAI,aAAa;EACf,MAAM,eAAe,MAAM;EAC3B;CACF;CACA,MAAM,EAAE,WAAW,MAAM,IAAI,MAAM;CACnC,QAAQ,WAAW,SAAS,IAAI;AAClC;AAEA,KAAK,CAAC,CAAC,OAAM,QAAO;CAClB,QAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,EAAE,GAAG;CAC1E,QAAQ,WAAW;AACrB,CAAC"}
|
|
@@ -71,6 +71,8 @@ interface StepDefinitionMeta {
|
|
|
71
71
|
interface ParsedScenario {
|
|
72
72
|
name: string;
|
|
73
73
|
file: string;
|
|
74
|
+
/** 1-based line of the `Scenario:`/`Scenario Outline:` keyword in the file. */
|
|
75
|
+
line?: number;
|
|
74
76
|
steps: ParsedStep[];
|
|
75
77
|
/**
|
|
76
78
|
* Gherkin tags in effect for this scenario, each including the leading `@`
|
|
@@ -164,26 +166,73 @@ declare class HookRegistry {
|
|
|
164
166
|
}
|
|
165
167
|
declare const globalHookRegistry: HookRegistry;
|
|
166
168
|
/**
|
|
167
|
-
* Run every registered
|
|
168
|
-
*
|
|
169
|
+
* Run every registered hook of a scope+timing **in registration order** (after
|
|
170
|
+
* hooks reversed by {@link HookRegistry.for}, so teardown unwinds setup). Used
|
|
171
|
+
* for feature hooks, where ordering matters. Throws if a hook throws, so the
|
|
169
172
|
* runner reports it against the enclosing boundary.
|
|
170
173
|
*/
|
|
171
174
|
declare function runHooks(scope: "feature" | "global", timing: HookTiming, registry?: HookRegistry): Promise<void>;
|
|
172
175
|
/**
|
|
173
|
-
* Run
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
176
|
+
* Run every registered hook of a scope+timing **concurrently**, resolving once
|
|
177
|
+
* all of them settle. This is how global `beforeAll`/`afterAll` run: independent
|
|
178
|
+
* setup/teardown steps fire in parallel with no ordering between them. A hook
|
|
179
|
+
* with a sequential requirement should sequence that work inside a single hook.
|
|
177
180
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* in each. Size global setup to be worker-safe (e.g. a server per worker).
|
|
183
|
-
* - Teardown is best-effort: after-hooks start on the worker's `beforeExit` and
|
|
184
|
-
* are not awaited by the runner, so keep them fast/synchronous.
|
|
181
|
+
* The runner calls this exactly once for `beforeAll` (before any scenario
|
|
182
|
+
* starts) and once for `afterAll` (after every scenario is done), so global
|
|
183
|
+
* setup/teardown brackets the whole run deterministically. Rejects if any hook
|
|
184
|
+
* rejects (via `Promise.all`), surfacing the first failure to the caller.
|
|
185
185
|
*/
|
|
186
|
-
declare function
|
|
186
|
+
declare function runHooksParallel(scope: "feature" | "global", timing: HookTiming, registry?: HookRegistry): Promise<void>;
|
|
187
187
|
//#endregion
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
//#region src/runtime/config.d.ts
|
|
189
|
+
/**
|
|
190
|
+
* User-facing runner configuration. The same shape is accepted from a
|
|
191
|
+
* `step-forge.config.ts` file (default export) and from CLI flags, with flags
|
|
192
|
+
* taking precedence. Everything is optional; {@link resolveConfig} fills in
|
|
193
|
+
* defaults.
|
|
194
|
+
*/
|
|
195
|
+
interface RunnerOptions {
|
|
196
|
+
/** Feature-file glob(s), relative to `cwd`. Defaults to every `.feature` file. */
|
|
197
|
+
features?: string | string[];
|
|
198
|
+
/** Step-module glob(s), relative to `cwd`. Defaults to every `.steps.ts` file. */
|
|
199
|
+
steps?: string | string[];
|
|
200
|
+
/**
|
|
201
|
+
* Module that default-exports a world factory `() => world`, relative to
|
|
202
|
+
* `cwd`. When omitted each scenario gets a fresh `BasicWorld`.
|
|
203
|
+
*/
|
|
204
|
+
world?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Max scenarios in flight at once. Defaults to `1` (serial), matching
|
|
207
|
+
* Cucumber's default execution model — scenarios often share module-level
|
|
208
|
+
* state via hooks, which only holds under serial execution. Raise it to opt
|
|
209
|
+
* into parallelism for isolated, I/O-bound suites.
|
|
210
|
+
*/
|
|
211
|
+
concurrency?: number;
|
|
212
|
+
/** Reporter name. Default `pretty`. */
|
|
213
|
+
reporter?: "pretty" | "progress";
|
|
214
|
+
/**
|
|
215
|
+
* Verbose output: report every scenario (pass, fail, skip) instead of only
|
|
216
|
+
* failures. Passed to whichever reporter is active. Default `false`.
|
|
217
|
+
*/
|
|
218
|
+
verbose?: boolean;
|
|
219
|
+
/** Only run scenarios whose name matches this (string → substring/regex). */
|
|
220
|
+
name?: string;
|
|
221
|
+
/** Cucumber tag expression, e.g. `@smoke and not @wip`. */
|
|
222
|
+
tags?: string;
|
|
223
|
+
}
|
|
224
|
+
/** Fully-resolved config: no optionals, globs kept as arrays, paths absolute. */
|
|
225
|
+
interface ResolvedConfig {
|
|
226
|
+
cwd: string;
|
|
227
|
+
features: string[];
|
|
228
|
+
steps: string[];
|
|
229
|
+
world?: string;
|
|
230
|
+
concurrency: number;
|
|
231
|
+
reporter: "pretty" | "progress";
|
|
232
|
+
verbose: boolean;
|
|
233
|
+
name?: string;
|
|
234
|
+
tags?: string;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { booleanParser as C, stringParser as E, Parser as S, numberParser as T, ParsedScenario as _, HookTiming as a, BasicWorld as b, ScenarioHookFn as c, runHooks as d, runHooksParallel as f, MatchedStep as g, Diagnostic as h, HookScope as i, ScenarioInfo as l, AnalyzerConfig as m, RunnerOptions as n, PlainHookFn as o, AnalysisRule as p, HookRegistry as r, RegisteredHook as s, ResolvedConfig as t, globalHookRegistry as u, ParsedStep as v, intParser as w, MergeableWorld as x, StepDefinitionMeta as y };
|
|
238
|
+
//# sourceMappingURL=config-C7PCYgYy.d.cts.map
|
|
@@ -71,6 +71,8 @@ interface StepDefinitionMeta {
|
|
|
71
71
|
interface ParsedScenario {
|
|
72
72
|
name: string;
|
|
73
73
|
file: string;
|
|
74
|
+
/** 1-based line of the `Scenario:`/`Scenario Outline:` keyword in the file. */
|
|
75
|
+
line?: number;
|
|
74
76
|
steps: ParsedStep[];
|
|
75
77
|
/**
|
|
76
78
|
* Gherkin tags in effect for this scenario, each including the leading `@`
|
|
@@ -164,26 +166,73 @@ declare class HookRegistry {
|
|
|
164
166
|
}
|
|
165
167
|
declare const globalHookRegistry: HookRegistry;
|
|
166
168
|
/**
|
|
167
|
-
* Run every registered
|
|
168
|
-
*
|
|
169
|
+
* Run every registered hook of a scope+timing **in registration order** (after
|
|
170
|
+
* hooks reversed by {@link HookRegistry.for}, so teardown unwinds setup). Used
|
|
171
|
+
* for feature hooks, where ordering matters. Throws if a hook throws, so the
|
|
169
172
|
* runner reports it against the enclosing boundary.
|
|
170
173
|
*/
|
|
171
174
|
declare function runHooks(scope: "feature" | "global", timing: HookTiming, registry?: HookRegistry): Promise<void>;
|
|
172
175
|
/**
|
|
173
|
-
* Run
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
176
|
+
* Run every registered hook of a scope+timing **concurrently**, resolving once
|
|
177
|
+
* all of them settle. This is how global `beforeAll`/`afterAll` run: independent
|
|
178
|
+
* setup/teardown steps fire in parallel with no ordering between them. A hook
|
|
179
|
+
* with a sequential requirement should sequence that work inside a single hook.
|
|
177
180
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* in each. Size global setup to be worker-safe (e.g. a server per worker).
|
|
183
|
-
* - Teardown is best-effort: after-hooks start on the worker's `beforeExit` and
|
|
184
|
-
* are not awaited by the runner, so keep them fast/synchronous.
|
|
181
|
+
* The runner calls this exactly once for `beforeAll` (before any scenario
|
|
182
|
+
* starts) and once for `afterAll` (after every scenario is done), so global
|
|
183
|
+
* setup/teardown brackets the whole run deterministically. Rejects if any hook
|
|
184
|
+
* rejects (via `Promise.all`), surfacing the first failure to the caller.
|
|
185
185
|
*/
|
|
186
|
-
declare function
|
|
186
|
+
declare function runHooksParallel(scope: "feature" | "global", timing: HookTiming, registry?: HookRegistry): Promise<void>;
|
|
187
187
|
//#endregion
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
//#region src/runtime/config.d.ts
|
|
189
|
+
/**
|
|
190
|
+
* User-facing runner configuration. The same shape is accepted from a
|
|
191
|
+
* `step-forge.config.ts` file (default export) and from CLI flags, with flags
|
|
192
|
+
* taking precedence. Everything is optional; {@link resolveConfig} fills in
|
|
193
|
+
* defaults.
|
|
194
|
+
*/
|
|
195
|
+
interface RunnerOptions {
|
|
196
|
+
/** Feature-file glob(s), relative to `cwd`. Defaults to every `.feature` file. */
|
|
197
|
+
features?: string | string[];
|
|
198
|
+
/** Step-module glob(s), relative to `cwd`. Defaults to every `.steps.ts` file. */
|
|
199
|
+
steps?: string | string[];
|
|
200
|
+
/**
|
|
201
|
+
* Module that default-exports a world factory `() => world`, relative to
|
|
202
|
+
* `cwd`. When omitted each scenario gets a fresh `BasicWorld`.
|
|
203
|
+
*/
|
|
204
|
+
world?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Max scenarios in flight at once. Defaults to `1` (serial), matching
|
|
207
|
+
* Cucumber's default execution model — scenarios often share module-level
|
|
208
|
+
* state via hooks, which only holds under serial execution. Raise it to opt
|
|
209
|
+
* into parallelism for isolated, I/O-bound suites.
|
|
210
|
+
*/
|
|
211
|
+
concurrency?: number;
|
|
212
|
+
/** Reporter name. Default `pretty`. */
|
|
213
|
+
reporter?: "pretty" | "progress";
|
|
214
|
+
/**
|
|
215
|
+
* Verbose output: report every scenario (pass, fail, skip) instead of only
|
|
216
|
+
* failures. Passed to whichever reporter is active. Default `false`.
|
|
217
|
+
*/
|
|
218
|
+
verbose?: boolean;
|
|
219
|
+
/** Only run scenarios whose name matches this (string → substring/regex). */
|
|
220
|
+
name?: string;
|
|
221
|
+
/** Cucumber tag expression, e.g. `@smoke and not @wip`. */
|
|
222
|
+
tags?: string;
|
|
223
|
+
}
|
|
224
|
+
/** Fully-resolved config: no optionals, globs kept as arrays, paths absolute. */
|
|
225
|
+
interface ResolvedConfig {
|
|
226
|
+
cwd: string;
|
|
227
|
+
features: string[];
|
|
228
|
+
steps: string[];
|
|
229
|
+
world?: string;
|
|
230
|
+
concurrency: number;
|
|
231
|
+
reporter: "pretty" | "progress";
|
|
232
|
+
verbose: boolean;
|
|
233
|
+
name?: string;
|
|
234
|
+
tags?: string;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { booleanParser as C, stringParser as E, Parser as S, numberParser as T, ParsedScenario as _, HookTiming as a, BasicWorld as b, ScenarioHookFn as c, runHooks as d, runHooksParallel as f, MatchedStep as g, Diagnostic as h, HookScope as i, ScenarioInfo as l, AnalyzerConfig as m, RunnerOptions as n, PlainHookFn as o, AnalysisRule as p, HookRegistry as r, RegisteredHook as s, ResolvedConfig as t, globalHookRegistry as u, ParsedStep as v, intParser as w, MergeableWorld as x, StepDefinitionMeta as y };
|
|
238
|
+
//# sourceMappingURL=config-C7PCYgYy.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as globalHookRegistry } from "./hooks-BDCMKeNq.js";
|
|
2
2
|
import { CucumberExpression, ParameterType, ParameterTypeRegistry } from "@cucumber/cucumber-expressions";
|
|
3
3
|
//#region src/runtime/engine.ts
|
|
4
4
|
const keywordToStepType = {
|
|
@@ -112,19 +112,23 @@ async function runScenario(scenario, compiled, makeWorld, hooks = globalHookRegi
|
|
|
112
112
|
});
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
|
+
let source;
|
|
115
116
|
try {
|
|
116
117
|
const { step: def, args } = matchStep(step, compiled);
|
|
118
|
+
source = def.source;
|
|
117
119
|
await def.execute(world, args);
|
|
118
120
|
steps.push({
|
|
119
121
|
step,
|
|
120
|
-
status: "passed"
|
|
122
|
+
status: "passed",
|
|
123
|
+
source
|
|
121
124
|
});
|
|
122
125
|
} catch (err) {
|
|
123
126
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
124
127
|
steps.push({
|
|
125
128
|
step,
|
|
126
129
|
status: "failed",
|
|
127
|
-
error
|
|
130
|
+
error,
|
|
131
|
+
source
|
|
128
132
|
});
|
|
129
133
|
fail(error);
|
|
130
134
|
}
|
|
@@ -137,10 +141,6 @@ async function runScenario(scenario, compiled, makeWorld, hooks = globalHookRegi
|
|
|
137
141
|
} catch (err) {
|
|
138
142
|
fail(err);
|
|
139
143
|
}
|
|
140
|
-
if (failed && firstError) {
|
|
141
|
-
const failing = steps.find((s) => s.status === "failed");
|
|
142
|
-
if (failing) attachFeatureFrame(firstError, scenario.file, failing.step);
|
|
143
|
-
}
|
|
144
144
|
return {
|
|
145
145
|
scenario,
|
|
146
146
|
status: failed ? "failed" : "passed",
|
|
@@ -157,25 +157,7 @@ async function runScenario(scenario, compiled, makeWorld, hooks = globalHookRegi
|
|
|
157
157
|
function now() {
|
|
158
158
|
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
159
159
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Prepend a synthetic stack frame pointing at the failing Gherkin step. Because
|
|
162
|
-
* the frame's file is the real `.feature` on disk, the test runner treats it as
|
|
163
|
-
* a source location and shows a code frame at the step — instead of us jamming
|
|
164
|
-
* `file:line` into the error message. The frame goes *above* the real stack, so
|
|
165
|
-
* the step-definition frames (the actual throw site) are preserved below it.
|
|
166
|
-
*/
|
|
167
|
-
function attachFeatureFrame(error, file, step) {
|
|
168
|
-
const frame = ` at ${`${step.effectiveKeyword} ${step.text}`} (${file}:${step.line}:${step.column})`;
|
|
169
|
-
const stack = error.stack;
|
|
170
|
-
if (!stack) {
|
|
171
|
-
error.stack = `${error.name}: ${error.message}\n${frame}`;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const firstFrame = stack.indexOf("\n at ");
|
|
175
|
-
if (firstFrame === -1) error.stack = `${stack}\n${frame}`;
|
|
176
|
-
else error.stack = stack.slice(0, firstFrame) + `\n${frame}` + stack.slice(firstFrame);
|
|
177
|
-
}
|
|
178
160
|
//#endregion
|
|
179
161
|
export { runScenario as i, UndefinedStepError as n, compileRegistry as r, AmbiguousStepError as t };
|
|
180
162
|
|
|
181
|
-
//# sourceMappingURL=engine-
|
|
163
|
+
//# sourceMappingURL=engine-DPVLEHBi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-DPVLEHBi.js","names":[],"sources":["../../src/runtime/engine.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n CucumberExpression,\n ParameterType,\n ParameterTypeRegistry,\n} from \"@cucumber/cucumber-expressions\";\nimport { ParsedScenario, ParsedStep } from \"../analyzer/types\";\nimport { MergeableWorld } from \"../world\";\nimport { globalHookRegistry, HookRegistry, ScenarioHookFn } from \"./hooks\";\nimport { RegisteredStep, StepRegistry, StepType } from \"./registry\";\n\nconst keywordToStepType: Record<ParsedStep[\"effectiveKeyword\"], StepType> = {\n Given: \"given\",\n When: \"when\",\n Then: \"then\",\n};\n\n/** A registered step paired with its compiled Cucumber expression. */\nexport interface CompiledStep {\n step: RegisteredStep;\n expression: CucumberExpression;\n}\n\nexport class UndefinedStepError extends Error {\n constructor(public readonly step: ParsedStep) {\n super(`Undefined step: ${step.effectiveKeyword} ${step.text}`);\n this.name = \"UndefinedStepError\";\n }\n}\n\nexport class AmbiguousStepError extends Error {\n constructor(\n public readonly step: ParsedStep,\n public readonly matches: RegisteredStep[]\n ) {\n super(\n `Ambiguous step: \"${step.text}\" matched ${matches.length} definitions:\\n` +\n matches.map(m => ` - ${m.expression}`).join(\"\\n\")\n );\n this.name = \"AmbiguousStepError\";\n }\n}\n\n/**\n * Compile a registry's steps into matchable Cucumber expressions **once** per\n * run. The result is reused for every scenario — compilation is pure and depends\n * only on the registry, so recompiling per scenario (as an earlier version did)\n * was wasted work proportional to scenarios × steps.\n */\nexport function compileRegistry(registry: StepRegistry): CompiledStep[] {\n return registry.all().map(step => {\n // Each step gets its own parameter-type registry (seeded with the\n // built-ins). A parser whose name is already registered — the built-in\n // `{int}`/`{float}`/`{string}`, or a repeat within the same step — reuses\n // that type; a novel name (e.g. `{boolean}`, `{color}`) is registered from\n // the parser's regexp + parse, so matching and coercion happen in one pass.\n const paramRegistry = new ParameterTypeRegistry();\n for (const parser of step.parsers) {\n if (paramRegistry.lookupByTypeName(parser.name)) continue;\n const regexps = Array.isArray(parser.regexp)\n ? parser.regexp\n : [parser.regexp];\n paramRegistry.defineParameterType(\n new ParameterType(parser.name, regexps, null, (value: string) =>\n parser.parse(value)\n )\n );\n }\n return {\n step,\n expression: new CucumberExpression(step.expression, paramRegistry),\n };\n });\n}\n\n/**\n * Find the single step definition matching a Gherkin step. Matching is\n * opinionated and strict: the keyword must line up with the step type, exactly\n * one definition must match, and undefined/ambiguous both throw rather than\n * silently skipping (unlike Cucumber's pending/undefined dance).\n */\nfunction matchStep(\n step: ParsedStep,\n compiled: CompiledStep[]\n): { step: RegisteredStep; args: unknown[] } {\n const expectedType = keywordToStepType[step.effectiveKeyword];\n const matches: { step: RegisteredStep; args: unknown[] }[] = [];\n\n for (const { step: def, expression } of compiled) {\n if (def.stepType !== expectedType) continue;\n const result = expression.match(step.text);\n if (result) {\n // The parsers are registered as the expression's parameter types, so the\n // captured values are already coerced (`{int}` → number, `{color}` → the\n // parser's T). `execute` consumes them as-is.\n matches.push({ step: def, args: result.map(a => a.getValue(null)) });\n }\n }\n\n if (matches.length === 0) throw new UndefinedStepError(step);\n if (matches.length > 1) {\n throw new AmbiguousStepError(\n step,\n matches.map(m => m.step)\n );\n }\n return matches[0];\n}\n\nexport interface StepResult {\n step: ParsedStep;\n status: \"passed\" | \"failed\" | \"skipped\";\n error?: Error;\n /**\n * Absolute `file:line:column` where the matched step is *defined* (its\n * `.step(...)` call site), for Cucumber-style reporting. Absent when no step\n * matched (undefined/ambiguous) or the step was skipped.\n */\n source?: string;\n durationMs?: number;\n}\n\nexport interface ScenarioResult {\n scenario: ParsedScenario;\n status: \"passed\" | \"failed\";\n steps: StepResult[];\n /**\n * The scenario's first error, if it failed. Usually the same object as the\n * failing step's `error`; for a hook failure there's no step to point at, so\n * this is the only place it surfaces. Reporters read this; the runner never\n * throws it.\n */\n error?: Error;\n /** Wall-clock duration of the whole scenario, in milliseconds. */\n durationMs?: number;\n}\n\n/**\n * Run one scenario against a pre-compiled step table. A fresh world is created\n * per scenario (state never leaks between scenarios). On the first failing step\n * the remaining steps are marked skipped, matching Cucumber's execution\n * semantics.\n *\n * Never throws for step or hook failures: it always resolves to a\n * `ScenarioResult` carrying the per-step breakdown and (on failure) the first\n * `error` with a synthetic `.feature` stack frame attached. Callers decide what\n * to do with a failure — the CLI runner reports it, a test-runner adapter can\n * re-throw `result.error`. It still rejects for truly exceptional conditions\n * (e.g. a bug in the engine itself), never for a normal test failure.\n *\n * Pass the compiled table from {@link compileRegistry} once and reuse it across\n * every scenario in the run.\n */\nexport async function runScenario(\n scenario: ParsedScenario,\n compiled: CompiledStep[],\n makeWorld: () => MergeableWorld<any, any, any>,\n hooks: HookRegistry = globalHookRegistry\n): Promise<ScenarioResult> {\n const start = now();\n const world = makeWorld();\n const scenarioInfo = { name: scenario.name, file: scenario.file };\n const steps: StepResult[] = [];\n let failed = false;\n let firstError: Error | undefined;\n\n const fail = (err: unknown) => {\n if (failed) return;\n failed = true;\n firstError = err instanceof Error ? err : new Error(String(err));\n };\n\n // before-scenario hooks: a throw here aborts the scenario before any step.\n try {\n for (const hook of hooks.for(\"scenario\", \"before\")) {\n await (hook.fn as ScenarioHookFn)({ world, scenario: scenarioInfo });\n }\n } catch (err) {\n fail(err);\n }\n\n for (const step of scenario.steps) {\n if (failed) {\n steps.push({ step, status: \"skipped\" });\n continue;\n }\n // `source` is captured before `execute` so a failing step still carries its\n // definition location; it stays undefined if matching itself throws\n // (undefined/ambiguous step).\n let source: string | undefined;\n try {\n const { step: def, args } = matchStep(step, compiled);\n source = def.source;\n await def.execute(world, args);\n steps.push({ step, status: \"passed\", source });\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n steps.push({ step, status: \"failed\", error, source });\n fail(error);\n }\n }\n\n // after-scenario hooks always run (teardown), even on failure. A hook failure\n // only becomes the scenario's error if nothing else failed first.\n for (const hook of hooks.for(\"scenario\", \"after\")) {\n try {\n await (hook.fn as ScenarioHookFn)({ world, scenario: scenarioInfo });\n } catch (err) {\n fail(err);\n }\n }\n\n return {\n scenario,\n status: failed ? \"failed\" : \"passed\",\n steps,\n error: firstError,\n durationMs: now() - start,\n };\n}\n\n/**\n * Monotonic-ish millisecond clock. `performance.now()` where available (Node &\n * Bun both expose it globally), falling back to `Date.now()`. Kept in one place\n * so timing is consistent across scenarios.\n */\nfunction now(): number {\n return typeof performance !== \"undefined\" ? performance.now() : Date.now();\n}\n"],"mappings":";;;AAWA,MAAM,oBAAsE;CAC1E,OAAO;CACP,MAAM;CACN,MAAM;AACR;AAQA,IAAa,qBAAb,cAAwC,MAAM;CAChB;CAA5B,YAAY,MAAkC;EAC5C,MAAM,mBAAmB,KAAK,iBAAiB,GAAG,KAAK,MAAM;EADnC,KAAA,OAAA;EAE1B,KAAK,OAAO;CACd;AACF;AAEA,IAAa,qBAAb,cAAwC,MAAM;CAE1B;CACA;CAFlB,YACE,MAC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