@autometa/test-builder 0.4.2 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/test-plan-builder.ts","../src/internal/utils.ts","../src/internal/nodes.ts","../src/internal/summaries.ts","../src/internal/scope-resolution.ts","../src/build-test-plan.ts"],"names":[],"mappings":";AAAA,SAAS,oBAAoB,mBAAmB,6BAA6B;AAC7E,SAAS,mCAAmC;;;ACD5C,OAAO,UAAU;AAYV,SAAS,cAAc,OAAuB;AACnD,SAAO,MAAM,KAAK;AACpB;AAEO,SAAS,iBAAiB,SAAyB;AACxD,SAAO,QAAQ,KAAK;AACtB;AAEO,SAAS,aAAa,KAAqB;AAChD,QAAM,UAAU,IAAI,QAAQ,UAAU,EAAE;AACxC,QAAM,aAAa,KAAK,UAAU,OAAO;AAEzC,SAAO,WAAW,QAAQ,WAAW,GAAG;AAC1C;AAEO,SAAS,iBAAiB,IAAoB;AACnD,SAAO,KAAK,EAAE;AAChB;AAEO,SAAS,mBAAmB,WAAmB,OAAuB;AAC3E,SAAO,KAAK,SAAS,IAAI,QAAQ,CAAC;AACpC;AAEO,SAAS,mBAAmB,UAAmD;AACpF,SAAO,SACJ,IAAI,CAAC,YAAY;AAChB,UAAM,UAAU,QAAQ,QAAQ,KAAK;AACrC,UAAM,OAAO,QAAQ,MAAM,KAAK;AAChC,UAAM,SAAS,QAAQ,UAAU;AACjC,QAAI,CAAC,QAAQ,KAAK,WAAW,GAAG;AAC9B,aAAO,GAAG,OAAO,GAAG,MAAM;AAAA,IAC5B;AACA,WAAO,GAAG,OAAO,KAAK,IAAI,GAAG,MAAM;AAAA,EACrC,CAAC,EACA,KAAK,KAAK;AACf;AAEO,SAAS,eACX,SACgB;AACnB,QAAM,SAAmB,CAAC;AAC1B,QAAM,OAAO,oBAAI,IAAY;AAE7B,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC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AACjE,QAAM,UAAU,iBAAiB,OAAO,EAAE,QAAQ,MAAM,EAAE;AAC1D,QAAM,SAAS,iBAAiB,QAAQ,YAAY,CAAC;AACrD,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,qCAAqC,OAAO,GAAG;AAAA,EACjE;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,SAA0B;AACnD,QAAM,aAAa,iBAAiB,OAAO,EAAE,QAAQ,MAAM,EAAE,EAAE,YAAY;AAC3E,SAAO,kBAAkB,IAAI,UAAU;AACzC;AAEA,SAAS,iBAAiB,YAAoC;AAC5D,SAAO,OAAO,eAAe,WAAW,aAAa,WAAW,SAAS;AAC3E;AAEA,IAAM,mBAAgD;AAAA,EACpD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AACP;AAEA,IAAM,oBAAoB,oBAAI,IAAY,CAAC,OAAO,OAAO,GAAG,CAAC;;;AKp8BtD,SAAS,cAAqB,SAAuD;AAC1F,QAAM,EAAE,SAAS,QAAQ,IAAI;AAC7B,gBAAc,OAAO;AACrB,gBAAc,OAAO;AAErB,QAAM,eACJ,QAAQ,gBAAgB,oBAAoB,SAAS,OAAO;AAE9D,SAAO,IAAI,gBAAgB,SAAS,cAAc,OAAO,EAAE,MAAM;AACnE;AAEA,SAAS,cAAc,SAAsE;AAC3F,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACF;AAEA,SAAS,cACP,SACiD;AACjD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,4DAA4D;AAAA,EAC9E;AACF","sourcesContent":["import { CucumberExpression, RegularExpression, ParameterTypeRegistry } from \"@cucumber/cucumber-expressions\";\nimport { createDefaultParameterTypes } from \"@autometa/cucumber-expressions\";\nimport type {\n ScopeExecutionAdapter,\n ScopeNode,\n ScenarioSummary,\n StepDefinition,\n StepExpression,\n StepKeyword,\n NormalizedStepOptions,\n ExecutionMode,\n ParameterRegistryLike,\n} from \"@autometa/scopes\";\nimport type {\n SimpleFeature,\n SimpleRule,\n SimpleScenario,\n SimpleScenarioOutline,\n SimpleStep,\n} from \"@autometa/gherkin\";\nimport type {\n FeatureNode,\n QualifiedPathSegment,\n RuleNode,\n ScenarioExecution,\n ScenarioNode,\n ScenarioOutlineExample,\n ScenarioOutlineNode,\n TestPlan,\n} from \"../types\";\nimport {\n createFeatureNode,\n createRuleNode,\n createScenarioNode,\n createScenarioOutlineExample,\n createScenarioOutlineNode,\n} from \"./nodes\";\nimport {\n ScenarioKindKey,\n ScenarioSummaryBuckets,\n bucketScenarioSummaries,\n createSummaryKey,\n describeSummary,\n} from \"./summaries\";\nimport {\n buildExampleSuffix,\n buildQualifiedName,\n buildScopeSuffix,\n cloneData,\n collectTags,\n combineSteps,\n createExampleData,\n groupCompiledScenarios,\n mergeData,\n normalizeKeyword,\n isRule,\n isScenario,\n isScenarioOutline,\n} from \"./utils\";\nimport { findChildScope } from \"./scope-resolution\";\n\nconst FEATURE_SEGMENT_KEY = \"feature\";\nconst RULE_SEGMENT_KEY = \"rule\";\nconst EXAMPLE_SEGMENT_KEY = \"Example\";\n\nexport class TestPlanBuilder<World> {\n private static readonly SUGGESTION_LIMIT_PER_GROUP = 3;\n /**\n * Similarity threshold in [0, 1].\n * 1.0 = identical, 0.0 = completely different.\n */\n private static readonly SUGGESTION_MIN_SIMILARITY_SAME_TYPE = 0.6;\n private static readonly SUGGESTION_MIN_SIMILARITY_DIFFERENT_TYPE = 0.85;\n private readonly executions: ScenarioExecution<World>[] = [];\n private readonly byId = new Map<string, ScenarioExecution<World>>();\n private readonly byQualifiedName = new Map<string, ScenarioExecution<World>>();\n private readonly featureScenarios: ScenarioNode<World>[] = [];\n private readonly featureScenarioOutlines: ScenarioOutlineNode<World>[] = [];\n private readonly featureRules: RuleNode<World>[] = [];\n private readonly ruleScenarioMap = new Map<RuleNode<World>, ScenarioNode<World>[]>();\n private readonly ruleOutlineMap = new Map<RuleNode<World>, ScenarioOutlineNode<World>[]>();\n private readonly outlineExamplesMap = new Map<ScenarioOutlineNode<World>, ScenarioOutlineExample<World>[]>();\n private readonly summaryBuckets: ScenarioSummaryBuckets<World>;\n private readonly featureSegment: QualifiedPathSegment;\n private readonly parameterRegistry: ParameterTypeRegistry;\n private featureNode!: FeatureNode<World>;\n\n constructor(\n private readonly feature: SimpleFeature,\n private readonly featureScope: ScopeNode<World>,\n private readonly adapter: ScopeExecutionAdapter<World>\n ) {\n const summaries = adapter\n .listScenarios()\n .filter((summary) => summary.feature.id === featureScope.id);\n this.summaryBuckets = bucketScenarioSummaries(summaries);\n this.featureSegment = {\n keyword: normalizeKeyword(feature.keyword ?? FEATURE_SEGMENT_KEY),\n name: feature.name,\n suffix: buildScopeSuffix(featureScope.id),\n };\n this.parameterRegistry = resolveParameterRegistry(adapter.getParameterRegistry?.());\n createDefaultParameterTypes<unknown>()(this.parameterRegistry);\n }\n\n build(): TestPlan<World> {\n this.featureNode = createFeatureNode({\n feature: this.feature,\n scope: this.featureScope,\n executions: this.executions,\n scenarios: this.featureScenarios,\n outlines: this.featureScenarioOutlines,\n rules: this.featureRules,\n });\n\n for (const element of this.feature.elements ?? []) {\n if (isRule(element)) {\n this.processRule(element);\n } else if (isScenarioOutline(element)) {\n this.processScenarioOutline(element, undefined);\n } else if (isScenario(element)) {\n this.processScenario(element, undefined);\n }\n }\n\n this.ensureAllSummariesConsumed();\n\n return new TestPlanImpl(\n this.featureNode,\n this.executions,\n this.byId,\n this.byQualifiedName\n );\n }\n\n private processRule(rule: SimpleRule): void {\n const ruleScope = findChildScope(this.featureScope, \"rule\", rule.name);\n const qualifiedName = buildQualifiedName([\n this.featureSegment,\n {\n keyword: normalizeKeyword(rule.keyword ?? RULE_SEGMENT_KEY),\n name: rule.name,\n suffix: buildScopeSuffix(ruleScope.id),\n },\n ]);\n\n const ruleScenarios: ScenarioNode<World>[] = [];\n const ruleOutlines: ScenarioOutlineNode<World>[] = [];\n\n const ruleNode = createRuleNode<World>({\n rule,\n scope: ruleScope,\n qualifiedName,\n scenarios: ruleScenarios,\n outlines: ruleOutlines,\n });\n\n this.ruleScenarioMap.set(ruleNode, ruleScenarios);\n this.ruleOutlineMap.set(ruleNode, ruleOutlines);\n this.featureRules.push(ruleNode);\n\n for (const element of rule.elements ?? []) {\n if (isScenarioOutline(element)) {\n this.processScenarioOutline(element, ruleNode);\n } else if (isScenario(element)) {\n this.processScenario(element, ruleNode);\n }\n }\n }\n\n private processScenario(\n gherkinScenario: SimpleScenario,\n ruleNode: RuleNode<World> | undefined\n ): void {\n const ruleScope = ruleNode?.scope;\n const summary = this.consumeSummary(\n \"scenario\",\n gherkinScenario.name,\n ruleScope\n );\n\n if (summary.scenario.kind !== \"scenario\") {\n throw new Error(\n `Scope mismatch: expected scenario kind 'scenario' but received '${summary.scenario.kind}' for '${gherkinScenario.name}'`\n );\n }\n\n const qualifiedName = buildQualifiedName([\n this.featureSegment,\n ...(ruleNode\n ? [\n {\n keyword: normalizeKeyword(ruleNode.keyword),\n name: ruleNode.name,\n suffix: buildScopeSuffix(ruleNode.scope.id),\n } as const,\n ]\n : []),\n {\n keyword: normalizeKeyword(gherkinScenario.keyword ?? \"Scenario\"),\n name: gherkinScenario.name,\n suffix: buildScopeSuffix(summary.scenario.id),\n },\n ]);\n\n const gherkinSteps = combineSteps(\n this.feature.background?.steps,\n ruleNode?.background?.steps,\n gherkinScenario.steps\n );\n\n const resolvedSteps = this.resolveStepDefinitions(summary, gherkinSteps, {\n scenario: gherkinScenario.name,\n ...(ruleNode ? { rule: ruleNode.name } : {}),\n });\n\n const scenarioData = cloneData(summary.scenario.data);\n const scenarioNode = createScenarioNode<World>({\n id: summary.id,\n feature: this.featureNode,\n name: gherkinScenario.name,\n keyword: gherkinScenario.keyword ?? \"Scenario\",\n qualifiedName,\n tags: collectTags(\n this.feature.tags,\n ruleNode?.rule.tags,\n gherkinScenario.tags,\n summary.feature.tags,\n summary.scenario.tags\n ),\n mode: summary.scenario.mode,\n pending: summary.scenario.pending,\n ...(summary.scenario.pendingReason\n ? { pendingReason: summary.scenario.pendingReason }\n : {}),\n scope: summary.scenario,\n summary,\n gherkin: gherkinScenario,\n gherkinSteps,\n steps: resolvedSteps,\n ancestors: summary.ancestors,\n ...(ruleNode ? { rule: ruleNode } : {}),\n ...(summary.scenario.timeout !== undefined ? { timeout: summary.scenario.timeout } : {}),\n ...(scenarioData ? { data: scenarioData } : {}),\n });\n\n if (ruleNode) {\n this.getRuleScenarios(ruleNode).push(scenarioNode);\n } else {\n this.featureScenarios.push(scenarioNode);\n }\n\n this.registerExecution(scenarioNode);\n }\n\n private processScenarioOutline(\n outline: SimpleScenarioOutline,\n ruleNode: RuleNode<World> | undefined\n ): void {\n const ruleScope = ruleNode?.scope;\n const summary = this.consumeSummary(\n \"scenarioOutline\",\n outline.name,\n ruleScope\n );\n\n if (summary.scenario.kind !== \"scenarioOutline\") {\n throw new Error(\n `Scope mismatch: expected scenario kind 'scenarioOutline' but received '${summary.scenario.kind}' for '${outline.name}'`\n );\n }\n\n const outlineQualifiedName = buildQualifiedName([\n this.featureSegment,\n ...(ruleNode\n ? [\n {\n keyword: normalizeKeyword(ruleNode.keyword),\n name: ruleNode.name,\n suffix: buildScopeSuffix(ruleNode.scope.id),\n } as const,\n ]\n : []),\n {\n keyword: normalizeKeyword(outline.keyword ?? \"Scenario Outline\"),\n name: outline.name,\n suffix: buildScopeSuffix(summary.scenario.id),\n },\n ]);\n\n const outlineData = cloneData(summary.scenario.data);\n const outlineExamples: ScenarioOutlineExample<World>[] = [];\n\n const outlineNode = createScenarioOutlineNode<World>({\n outline,\n summary,\n scope: summary.scenario,\n keyword: outline.keyword ?? \"Scenario Outline\",\n name: outline.name,\n qualifiedName: outlineQualifiedName,\n tags: collectTags(\n this.feature.tags,\n ruleNode?.rule.tags,\n outline.tags,\n summary.feature.tags,\n summary.scenario.tags\n ),\n mode: summary.scenario.mode,\n pending: summary.scenario.pending,\n ...(summary.scenario.pendingReason\n ? { pendingReason: summary.scenario.pendingReason }\n : {}),\n ancestors: summary.ancestors,\n feature: this.featureNode,\n ...(summary.scenario.timeout !== undefined ? { timeout: summary.scenario.timeout } : {}),\n ...(outlineData ? { data: outlineData } : {}),\n ...(ruleNode ? { rule: ruleNode } : {}),\n examples: outlineExamples,\n });\n\n this.outlineExamplesMap.set(outlineNode, outlineExamples);\n\n if (ruleNode) {\n this.getRuleOutlines(ruleNode).push(outlineNode);\n } else {\n this.featureScenarioOutlines.push(outlineNode);\n }\n\n const compiledByGroup = groupCompiledScenarios(outline.compiledScenarios);\n\n for (const group of outline.exampleGroups ?? []) {\n const compiledForGroup = compiledByGroup.get(group.id) ?? [];\n compiledForGroup.sort((a, b) => a.exampleIndex - b.exampleIndex);\n\n for (const compiled of compiledForGroup) {\n const qualifiedName = buildQualifiedName([\n this.featureSegment,\n ...(ruleNode\n ? [\n {\n keyword: normalizeKeyword(ruleNode.keyword),\n name: ruleNode.name,\n suffix: buildScopeSuffix(ruleNode.scope.id),\n } as const,\n ]\n : []),\n {\n keyword: normalizeKeyword(outline.keyword ?? \"Scenario Outline\"),\n name: outline.name,\n suffix: buildScopeSuffix(summary.scenario.id),\n },\n {\n keyword: EXAMPLE_SEGMENT_KEY,\n name: compiled.name,\n suffix: buildExampleSuffix(compiled.id, compiled.exampleIndex),\n },\n ]);\n\n const gherkinSteps = combineSteps(\n this.feature.background?.steps,\n ruleNode?.background?.steps,\n compiled.steps\n );\n\n const resolvedSteps = this.resolveStepDefinitions(summary, gherkinSteps, {\n scenario: compiled.name,\n outline: outline.name,\n ...(ruleNode ? { rule: ruleNode.name } : {}),\n });\n\n const exampleData = mergeData(\n cloneData(summary.scenario.data),\n createExampleData(group, compiled)\n );\n\n const exampleExecution = createScenarioOutlineExample<World>({\n id: compiled.id,\n feature: this.featureNode,\n outline: outlineNode,\n name: compiled.name,\n keyword: compiled.keyword ?? outline.keyword ?? \"Scenario Outline\",\n qualifiedName,\n tags: collectTags(\n this.feature.tags,\n ruleNode?.rule.tags,\n outline.tags,\n group.tags,\n compiled.tags,\n summary.feature.tags,\n summary.scenario.tags\n ),\n mode: summary.scenario.mode,\n pending: summary.scenario.pending,\n ...(summary.scenario.pendingReason\n ? { pendingReason: summary.scenario.pendingReason }\n : {}),\n scope: summary.scenario,\n summary,\n gherkin: compiled,\n gherkinSteps,\n steps: resolvedSteps,\n ancestors: summary.ancestors,\n exampleGroup: group,\n exampleIndex: compiled.exampleIndex,\n ...(ruleNode ? { rule: ruleNode } : {}),\n ...(summary.scenario.timeout !== undefined ? { timeout: summary.scenario.timeout } : {}),\n ...(exampleData ? { data: exampleData } : {}),\n });\n\n this.getOutlineExamples(outlineNode).push(exampleExecution);\n this.registerExecution(exampleExecution);\n }\n }\n }\n\n private consumeSummary(\n kind: ScenarioKindKey,\n scenarioName: string,\n parentScope: ScopeNode<World> | undefined\n ): ScenarioSummary<World> {\n const key = createSummaryKey(kind, scenarioName, parentScope?.id);\n const bucket = this.summaryBuckets.get(key);\n\n if (!bucket || bucket.length === 0) {\n throw new Error(\n `Could not find a registered ${kind} scope for '${scenarioName}'${parentScope ? ` within '${parentScope.name}'` : \"\"}`\n );\n }\n\n const summary = bucket.shift() as ScenarioSummary<World>;\n if (bucket.length === 0) {\n this.summaryBuckets.delete(key);\n }\n return summary;\n }\n\n private registerExecution(execution: ScenarioExecution<World>): void {\n if (this.byId.has(execution.id)) {\n throw new Error(\n `Duplicate scenario identifier detected: '${execution.id}' for '${execution.qualifiedName}'`\n );\n }\n if (this.byQualifiedName.has(execution.qualifiedName)) {\n throw new Error(\n `Duplicate qualified scenario name detected: '${execution.qualifiedName}'`\n );\n }\n this.executions.push(execution);\n this.byId.set(execution.id, execution);\n this.byQualifiedName.set(execution.qualifiedName, execution);\n }\n\n private ensureAllSummariesConsumed(): void {\n const leftovers: string[] = [];\n for (const bucket of this.summaryBuckets.values()) {\n for (const summary of bucket) {\n leftovers.push(describeSummary(summary));\n }\n }\n\n if (leftovers.length > 0) {\n throw new Error(\n `The following scope scenarios were not matched to Gherkin nodes for feature '${this.feature.name}': ${leftovers.join(\", \")}`\n );\n }\n }\n\n private getRuleScenarios(rule: RuleNode<World>): ScenarioNode<World>[] {\n const list = this.ruleScenarioMap.get(rule);\n if (!list) {\n throw new Error(`Rule '${rule.name}' has no associated scenario registry`);\n }\n return list;\n }\n\n private getRuleOutlines(rule: RuleNode<World>): ScenarioOutlineNode<World>[] {\n const list = this.ruleOutlineMap.get(rule);\n if (!list) {\n throw new Error(`Rule '${rule.name}' has no associated scenario outline registry`);\n }\n return list;\n }\n\n private getOutlineExamples(\n outline: ScenarioOutlineNode<World>\n ): ScenarioOutlineExample<World>[] {\n const list = this.outlineExamplesMap.get(outline);\n if (!list) {\n throw new Error(\n `Scenario outline '${outline.name}' has no associated example registry`\n );\n }\n return list;\n }\n\n private resolveStepDefinitions(\n summary: ScenarioSummary<World>,\n gherkinSteps: readonly SimpleStep[],\n context: StepResolutionContext\n ): StepDefinition<World>[] {\n if (summary.steps.length === 0) {\n if (gherkinSteps.length === 0) {\n return [];\n }\n\n return gherkinSteps.map((step, index) =>\n this.createMissingStepDefinition(summary, context, step, index)\n );\n }\n\n const remaining = new Set(summary.steps);\n const ordered: StepDefinition<World>[] = [];\n const matchers = new Map<StepDefinition<World>, StepMatcher>();\n let encounteredMissing = false;\n\n for (const step of gherkinSteps) {\n const matched = this.findMatchingStepDefinition(\n step,\n summary.steps,\n remaining,\n matchers\n );\n\n if (!matched) {\n ordered.push(\n this.createMissingStepDefinition(\n summary,\n context,\n step,\n ordered.length\n )\n );\n encounteredMissing = true;\n continue;\n }\n\n ordered.push(matched);\n remaining.delete(matched);\n }\n\n // Note: It's normal for some step definitions to remain unused in a scenario.\n // Each scenario only uses the steps it needs, so we don't throw an error for unused steps.\n\n if (encounteredMissing) {\n return ordered;\n }\n\n return ordered;\n }\n\n private findMatchingStepDefinition(\n step: SimpleStep,\n definitions: readonly StepDefinition<World>[],\n remaining: Set<StepDefinition<World>>,\n matchers: Map<StepDefinition<World>, StepMatcher>\n ): StepDefinition<World> | undefined {\n const rawKeyword = normalizeKeyword(step.keyword ?? \"\");\n const wildcard = isFlexibleKeyword(rawKeyword);\n const keyword = wildcard ? undefined : normalizeGherkinStepKeyword(rawKeyword);\n\n const candidates = definitions.filter((definition) => {\n if (!remaining.has(definition)) {\n return false;\n }\n if (wildcard) {\n return true;\n }\n return keyword ? definition.keyword === keyword : false;\n });\n\n for (const definition of candidates) {\n if (this.matchesStepExpression(definition, step.text, matchers)) {\n return definition;\n }\n }\n\n return undefined;\n }\n\n private matchesStepExpression(\n definition: StepDefinition<World>,\n text: string,\n matchers: Map<StepDefinition<World>, StepMatcher>\n ): boolean {\n let matcher = matchers.get(definition);\n if (!matcher) {\n matcher = this.createMatcher(definition.expression);\n matchers.set(definition, matcher);\n }\n return matcher(text);\n }\n\n private createMatcher(expression: StepExpression): StepMatcher {\n if (expression instanceof RegExp) {\n const regex = new RegExp(expression.source, expression.flags);\n const evaluator = new RegularExpression(regex, this.parameterRegistry);\n return (text: string) => evaluator.match(text) !== null;\n }\n\n try {\n const cucumberExpression = new CucumberExpression(\n expression,\n this.parameterRegistry\n );\n return (text: string) => cucumberExpression.match(text) !== null;\n } catch {\n const literal = expression;\n return (text: string) => text === literal;\n }\n }\n\n private buildMissingStepDefinitionMessage(\n context: StepResolutionContext,\n step: SimpleStep,\n definitions: readonly StepDefinition<World>[]\n ): string {\n const keyword = (step.keyword ?? \"\").trim();\n const display = keyword.length > 0 ? `${keyword} ${step.text}` : step.text;\n const lines: string[] = [\n \"No step definition matched:\",\n \"\",\n `'${display}'`,\n \"\",\n this.buildMissingStepContextLine(context),\n ];\n\n const suggestions = this.resolveClosestStepDefinitionSuggestions(step, definitions);\n if (suggestions.sameType.length === 0 && suggestions.differentType.length === 0) {\n return lines.join(\"\\n\");\n }\n\n lines.push(\"\", \"Some close matches were found:\");\n\n if (suggestions.sameType.length > 0) {\n lines.push(\" Close matches with the same step type:\");\n for (const suggestion of suggestions.sameType) {\n lines.push(` - ${suggestion}`);\n }\n }\n\n if (suggestions.differentType.length > 0) {\n lines.push(\" Close matches with different step type:\");\n for (const suggestion of suggestions.differentType) {\n lines.push(` - ${suggestion}`);\n }\n }\n\n return lines.join(\"\\n\");\n }\n\n private buildMissingStepContextLine(context: StepResolutionContext): string {\n const parts = [`in scenario '${context.scenario}'`];\n if (context.outline) {\n parts.push(`of outline '${context.outline}'`);\n }\n if (context.rule) {\n parts.push(`within rule '${context.rule}'`);\n }\n parts.push(`for feature '${this.feature.name}'.`);\n return parts.join(\" \");\n }\n\n private buildUnusedStepDefinitionsMessage(\n context: StepResolutionContext,\n extras: readonly string[]\n ): string {\n const segments = [\n `The following step definitions were not matched to Gherkin steps in scenario '${context.scenario}'`,\n ];\n if (context.outline) {\n segments.push(`of outline '${context.outline}'`);\n }\n if (context.rule) {\n segments.push(`within rule '${context.rule}'`);\n }\n segments.push(`for feature '${this.feature.name}': ${extras.join(\", \")}`);\n return segments.join(\" \");\n }\n\n private describeStepDefinition(definition: StepDefinition<World>): string {\n return `${definition.keyword} ${formatExpression(definition.expression)}`;\n }\n\n private createMissingStepDefinition(\n summary: ScenarioSummary<World>,\n context: StepResolutionContext,\n step: SimpleStep,\n index: number\n ): StepDefinition<World> {\n const message = this.buildMissingStepDefinitionMessage(\n context,\n step,\n summary.steps\n );\n\n return {\n id: `${summary.id}:missing-step:${index}`,\n keyword: this.resolveStepKeyword(step),\n expression: step.text,\n handler: () => {\n throw new Error(message);\n },\n options: this.createFallbackStepOptions(summary.scenario.mode),\n } satisfies StepDefinition<World>;\n }\n\n private resolveStepKeyword(step: SimpleStep): StepKeyword {\n const raw = normalizeKeyword(step.keyword ?? \"\");\n if (isFlexibleKeyword(raw)) {\n return \"And\";\n }\n\n try {\n return normalizeGherkinStepKeyword(raw);\n } catch {\n return \"Given\";\n }\n }\n\n private createFallbackStepOptions(mode: ExecutionMode): NormalizedStepOptions {\n return {\n tags: [],\n mode,\n } satisfies NormalizedStepOptions;\n }\n\n private resolveClosestStepDefinitionSuggestions(\n step: SimpleStep,\n definitions: readonly StepDefinition<World>[]\n ): { sameType: string[]; differentType: string[] } {\n if (definitions.length === 0) {\n return { sameType: [], differentType: [] };\n }\n\n const desiredKeyword = this.tryNormalizeKeyword(step.keyword);\n const target = this.normalizeForDistance(step.text);\n\n const candidates = definitions\n .map((definition) => {\n const candidateText = this.normalizeForDistance(\n formatExpression(definition.expression)\n );\n const distance = this.computeEditDistance(target, candidateText);\n const similarity = this.computeSimilarity(target, candidateText, distance);\n return {\n definition,\n description: this.describeStepDefinition(definition),\n distance,\n similarity,\n };\n });\n\n candidates.sort((a, b) => a.distance - b.distance);\n\n const sameType: string[] = [];\n const differentType: string[] = [];\n\n for (const candidate of candidates) {\n const isSameType =\n !desiredKeyword || candidate.definition.keyword === desiredKeyword;\n\n if (isSameType) {\n if (\n candidate.similarity <\n TestPlanBuilder.SUGGESTION_MIN_SIMILARITY_SAME_TYPE\n ) {\n continue;\n }\n if (sameType.length < TestPlanBuilder.SUGGESTION_LIMIT_PER_GROUP) {\n sameType.push(candidate.description);\n }\n continue;\n }\n\n if (\n candidate.similarity <\n TestPlanBuilder.SUGGESTION_MIN_SIMILARITY_DIFFERENT_TYPE\n ) {\n continue;\n }\n if (differentType.length < TestPlanBuilder.SUGGESTION_LIMIT_PER_GROUP) {\n differentType.push(candidate.description);\n }\n\n if (\n sameType.length >= TestPlanBuilder.SUGGESTION_LIMIT_PER_GROUP &&\n differentType.length >= TestPlanBuilder.SUGGESTION_LIMIT_PER_GROUP\n ) {\n break;\n }\n }\n\n return { sameType, differentType };\n }\n\n private normalizeForDistance(value: string): string {\n return value\n .toLowerCase()\n .replace(/\\s+/g, \" \")\n .trim();\n }\n\n private computeSimilarity(a: string, b: string, distance: number): number {\n const maxLen = Math.max(a.length, b.length);\n if (maxLen === 0) {\n return 1;\n }\n const normalized = 1 - distance / maxLen;\n return Math.max(0, Math.min(1, normalized));\n }\n\n private computeEditDistance(a: string, b: string): number {\n if (a === b) {\n return 0;\n }\n\n const rows = a.length + 1;\n const cols = b.length + 1;\n const matrix: number[][] = Array.from({ length: rows }, () => Array<number>(cols).fill(0));\n\n for (let i = 0; i < rows; i++) {\n const row = matrix[i];\n if (!row) {\n throw new Error(\"Internal error: matrix row missing\");\n }\n row[0] = i;\n }\n\n const row0 = matrix[0];\n if (!row0) {\n throw new Error(\"Internal error: matrix[0] missing\");\n }\n for (let j = 0; j < cols; j++) {\n row0[j] = j;\n }\n\n for (let i = 1; i < rows; i++) {\n const row = matrix[i];\n const prevRow = matrix[i - 1];\n if (!row || !prevRow) {\n throw new Error(\"Internal error: matrix row missing\");\n }\n\n for (let j = 1; j < cols; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n const deletion = (prevRow[j] ?? 0) + 1;\n const insertion = (row[j - 1] ?? 0) + 1;\n const substitution = (prevRow[j - 1] ?? 0) + cost;\n row[j] = Math.min(deletion, insertion, substitution);\n }\n }\n\n const lastRow = matrix[rows - 1];\n if (!lastRow) {\n throw new Error(\"Internal error: last matrix row missing\");\n }\n const result = lastRow[cols - 1];\n if (result === undefined) {\n throw new Error(\"Internal error: matrix result missing\");\n }\n return result;\n }\n\n private tryNormalizeKeyword(keyword: string | undefined): StepKeyword | undefined {\n if (!keyword) {\n return undefined;\n }\n\n const raw = normalizeKeyword(keyword);\n if (isFlexibleKeyword(raw)) {\n return undefined;\n }\n\n try {\n return normalizeGherkinStepKeyword(raw);\n } catch {\n return undefined;\n }\n }\n}\n\nclass TestPlanImpl<World> implements TestPlan<World> {\n constructor(\n readonly feature: FeatureNode<World>,\n private readonly executions: readonly ScenarioExecution<World>[],\n private readonly byId: ReadonlyMap<string, ScenarioExecution<World>>,\n private readonly byQualifiedName: ReadonlyMap<string, ScenarioExecution<World>>\n ) {}\n\n listExecutables(): readonly ScenarioExecution<World>[] {\n return this.executions;\n }\n\n listFailed(): readonly ScenarioExecution<World>[] {\n return this.executions.filter((execution) => execution.result.status === \"failed\");\n }\n\n findById(id: string): ScenarioExecution<World> | undefined {\n return this.byId.get(id);\n }\n\n findByQualifiedName(name: string): ScenarioExecution<World> | undefined {\n return this.byQualifiedName.get(name);\n }\n}\n\ntype StepMatcher = (text: string) => boolean;\n\ninterface StepResolutionContext {\n readonly scenario: string;\n readonly outline?: string;\n readonly rule?: string;\n}\n\nfunction resolveParameterRegistry(\n parameterRegistry: ParameterRegistryLike | undefined\n): ParameterTypeRegistry {\n if (!parameterRegistry) {\n return new ParameterTypeRegistry();\n }\n if (isParameterTypeRegistry(parameterRegistry)) {\n return parameterRegistry;\n }\n const candidate = (parameterRegistry as { registry?: ParameterTypeRegistry }).registry;\n if (isParameterTypeRegistry(candidate)) {\n return candidate;\n }\n return new ParameterTypeRegistry();\n}\n\nfunction isParameterTypeRegistry(value: unknown): value is ParameterTypeRegistry {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n if (value instanceof ParameterTypeRegistry) {\n return true;\n }\n const registry = value as ParameterTypeRegistry;\n return (\n typeof registry.lookupByTypeName === \"function\" &&\n typeof registry.defineParameterType === \"function\"\n );\n}\n\nfunction normalizeGherkinStepKeyword(keyword: string): StepKeyword {\n const trimmed = normalizeKeyword(keyword).replace(/:$/, \"\");\n const mapped = STEP_KEYWORD_MAP[trimmed.toLowerCase()];\n if (!mapped) {\n throw new Error(`Unsupported Gherkin step keyword '${keyword}'`);\n }\n return mapped;\n}\n\nfunction isFlexibleKeyword(keyword: string): boolean {\n const normalized = normalizeKeyword(keyword).replace(/:$/, \"\").toLowerCase();\n return FLEXIBLE_KEYWORDS.has(normalized);\n}\n\nfunction formatExpression(expression: StepExpression): string {\n return typeof expression === \"string\" ? expression : expression.toString();\n}\n\nconst STEP_KEYWORD_MAP: Record<string, StepKeyword> = {\n given: \"Given\",\n when: \"When\",\n then: \"Then\",\n and: \"And\",\n but: \"But\",\n};\n\nconst FLEXIBLE_KEYWORDS = new Set<string>([\"and\", \"but\", \"*\"]);\n","import path from \"node:path\";\nimport type {\n SimpleCompiledScenario,\n SimpleExampleGroup,\n SimpleFeatureElement,\n SimpleRule,\n SimpleScenario,\n SimpleScenarioOutline,\n SimpleStep,\n} from \"@autometa/gherkin\";\nimport type { QualifiedPathSegment } from \"../types\";\n\nexport function normalizeName(value: string): string {\n return value.trim();\n}\n\nexport function normalizeKeyword(keyword: string): string {\n return keyword.trim();\n}\n\nexport function normalizeUri(uri: string): string {\n const cleaned = uri.replace(/^file:/, \"\");\n const normalized = path.normalize(cleaned);\n // Ensure consistent posix-style separators regardless of host platform\n return normalized.replace(/[\\\\/]+/g, \"/\");\n}\n\nexport function buildScopeSuffix(id: string): string {\n return ` [${id}]`;\n}\n\nexport function buildExampleSuffix(exampleId: string, index: number): string {\n return ` [${exampleId}#${index + 1}]`;\n}\n\nexport function buildQualifiedName(segments: readonly QualifiedPathSegment[]): string {\n return segments\n .map((segment) => {\n const keyword = segment.keyword.trim();\n const name = segment.name?.trim();\n const suffix = segment.suffix ?? \"\";\n if (!name || name.length === 0) {\n return `${keyword}${suffix}`;\n }\n return `${keyword}: ${name}${suffix}`;\n })\n .join(\" > \");\n}\n\nexport function collectTags(\n ...sources: ReadonlyArray<readonly string[] | undefined>\n): readonly string[] {\n const result: string[] = [];\n const seen = new Set<string>();\n\n for (const source of sources) {\n if (!source) {\n continue;\n }\n for (const tag of source) {\n if (!seen.has(tag)) {\n seen.add(tag);\n result.push(tag);\n }\n }\n }\n\n return result;\n}\n\nexport function combineSteps(\n featureSteps: readonly SimpleStep[] | undefined,\n ruleSteps: readonly SimpleStep[] | undefined,\n scenarioSteps: readonly SimpleStep[] | undefined\n): readonly SimpleStep[] {\n return [\n ...(featureSteps ?? []),\n ...(ruleSteps ?? []),\n ...(scenarioSteps ?? []),\n ];\n}\n\nexport function cloneData(\n data: Record<string, unknown> | undefined\n): Record<string, unknown> | undefined {\n if (!data) {\n return undefined;\n }\n return { ...data };\n}\n\nexport function mergeData(\n base: Record<string, unknown> | undefined,\n extra: Record<string, unknown> | undefined\n): Record<string, unknown> | undefined {\n if (!base && !extra) {\n return undefined;\n }\n return {\n ...(base ?? {}),\n ...(extra ?? {}),\n };\n}\n\nexport function createExampleData(\n group: SimpleExampleGroup,\n compiled: SimpleCompiledScenario\n): Record<string, unknown> | undefined {\n const headers = group.tableHeader ?? [];\n const rows = group.tableBody ?? [];\n const row = rows[compiled.exampleIndex];\n if (!row) {\n return undefined;\n }\n const values: Record<string, string> = {};\n headers.forEach((header, index) => {\n const key = header.trim();\n if (key.length === 0) {\n return;\n }\n values[key] = row[index] ?? \"\";\n });\n return {\n example: {\n group: {\n id: group.id,\n name: group.name,\n tags: [...group.tags],\n },\n index: compiled.exampleIndex,\n values,\n },\n };\n}\n\nexport function normalizeError(error: unknown): Error {\n if (error instanceof Error) {\n return error;\n }\n if (typeof error === \"string\") {\n return new Error(error);\n }\n return new Error(JSON.stringify(error));\n}\n\nexport function groupCompiledScenarios(\n compiled: readonly SimpleCompiledScenario[]\n): Map<string, SimpleCompiledScenario[]> {\n const map = new Map<string, SimpleCompiledScenario[]>();\n for (const scenario of compiled ?? []) {\n const list = map.get(scenario.exampleGroupId) ?? [];\n list.push(scenario);\n map.set(scenario.exampleGroupId, list);\n }\n return map;\n}\n\nexport function isRule(element: SimpleFeatureElement): element is SimpleRule {\n return \"elements\" in element && Array.isArray(element.elements);\n}\n\nexport function isScenarioOutline(\n element: SimpleFeatureElement | SimpleScenario | SimpleScenarioOutline | SimpleRule\n): element is SimpleScenarioOutline {\n return \"exampleGroups\" in element;\n}\n\nexport function isScenario(\n element: SimpleFeatureElement | SimpleScenario\n): element is SimpleScenario {\n return (\n \"steps\" in element &&\n !(\"exampleGroups\" in element) &&\n !(\"elements\" in element)\n );\n}\n","import type {\n ExecutionMode,\n ScopeNode,\n ScenarioSummary,\n StepDefinition,\n TimeoutSpec,\n} from \"@autometa/scopes\";\nimport type {\n SimpleCompiledScenario,\n SimpleExampleGroup,\n SimpleFeature,\n SimpleRule,\n SimpleScenario,\n SimpleScenarioOutline,\n SimpleStep,\n} from \"@autometa/gherkin\";\nimport type {\n FeatureNode,\n RuleNode,\n ScenarioExecution,\n ScenarioNode,\n ScenarioOutlineExample,\n ScenarioOutlineNode,\n ScenarioResult,\n} from \"../types\";\nimport {\n cloneData,\n normalizeError,\n normalizeKeyword,\n} from \"./utils\";\n\nexport interface FeatureNodeInit<World> {\n readonly feature: SimpleFeature;\n readonly scope: ScopeNode<World>;\n readonly executions: ScenarioExecution<World>[];\n readonly scenarios: ScenarioNode<World>[];\n readonly outlines: ScenarioOutlineNode<World>[];\n readonly rules: RuleNode<World>[];\n}\n\nexport interface RuleNodeInit<World> {\n readonly rule: SimpleRule;\n readonly scope: ScopeNode<World>;\n readonly qualifiedName: string;\n readonly scenarios: ScenarioNode<World>[];\n readonly outlines: ScenarioOutlineNode<World>[];\n}\n\nexport interface ScenarioExecutionInit<World, Gherkin extends SimpleScenario | SimpleCompiledScenario> {\n readonly id: string;\n readonly feature: FeatureNode<World>;\n readonly rule?: RuleNode<World>;\n readonly outline?: ScenarioOutlineNode<World>;\n readonly name: string;\n readonly keyword: string;\n readonly qualifiedName: string;\n readonly tags: readonly string[];\n readonly mode: ExecutionMode;\n readonly pending: boolean;\n readonly pendingReason?: string;\n readonly timeout?: TimeoutSpec;\n readonly data?: Record<string, unknown>;\n readonly scope: ScopeNode<World>;\n readonly summary: ScenarioSummary<World>;\n readonly gherkin: Gherkin;\n readonly gherkinSteps: readonly SimpleStep[];\n readonly steps: readonly StepDefinition<World>[];\n readonly ancestors: readonly ScopeNode<World>[];\n readonly exampleGroup?: SimpleExampleGroup;\n readonly exampleIndex?: number;\n}\n\nexport interface ScenarioOutlineExampleInit<World>\n extends ScenarioExecutionInit<World, SimpleCompiledScenario> {\n readonly outline: ScenarioOutlineNode<World>;\n readonly exampleGroup: SimpleExampleGroup;\n readonly exampleIndex: number;\n}\n\nexport interface ScenarioOutlineNodeInit<World> {\n readonly outline: SimpleScenarioOutline;\n readonly summary: ScenarioSummary<World>;\n readonly scope: ScopeNode<World>;\n readonly keyword: string;\n readonly name: string;\n readonly qualifiedName: string;\n readonly tags: readonly string[];\n readonly mode: ExecutionMode;\n readonly pending: boolean;\n readonly pendingReason?: string;\n readonly timeout?: TimeoutSpec;\n readonly data?: Record<string, unknown>;\n readonly ancestors: readonly ScopeNode<World>[];\n readonly rule?: RuleNode<World>;\n readonly feature: FeatureNode<World>;\n readonly examples: ScenarioOutlineExample<World>[];\n}\n\nexport function createFeatureNode<World>(init: FeatureNodeInit<World>): FeatureNode<World> {\n return new FeatureNodeImpl(init);\n}\n\nexport function createRuleNode<World>(init: RuleNodeInit<World>): RuleNode<World> {\n return new RuleNodeImpl(init);\n}\n\nexport function createScenarioNode<World>(\n init: ScenarioExecutionInit<World, SimpleScenario>\n): ScenarioNode<World> {\n return new ScenarioNodeImpl(init);\n}\n\nexport function createScenarioOutlineNode<World>(\n init: ScenarioOutlineNodeInit<World>\n): ScenarioOutlineNode<World> {\n return new ScenarioOutlineNodeImpl(init);\n}\n\nexport function createScenarioOutlineExample<World>(\n init: ScenarioOutlineExampleInit<World>\n): ScenarioOutlineExample<World> {\n return new ScenarioOutlineExampleImpl(init);\n}\n\nclass FeatureNodeImpl<World> implements FeatureNode<World> {\n readonly type = \"feature\" as const;\n readonly scenarios: ScenarioNode<World>[];\n readonly scenarioOutlines: ScenarioOutlineNode<World>[];\n readonly rules: RuleNode<World>[];\n readonly name: string;\n readonly keyword: string;\n readonly background?: SimpleScenario;\n readonly feature: SimpleFeature;\n readonly scope: ScopeNode<World>;\n private readonly executions: ScenarioExecution<World>[];\n\n constructor(init: FeatureNodeInit<World>) {\n this.feature = init.feature;\n this.scope = init.scope;\n this.executions = init.executions;\n this.scenarios = init.scenarios;\n this.scenarioOutlines = init.outlines;\n this.rules = init.rules;\n this.name = init.feature.name;\n this.keyword = normalizeKeyword(init.feature.keyword ?? \"Feature\");\n if (init.feature.background) {\n this.background = init.feature.background;\n }\n }\n\n listExecutables(): readonly ScenarioExecution<World>[] {\n return this.executions;\n }\n}\n\nclass RuleNodeImpl<World> implements RuleNode<World> {\n readonly type = \"rule\" as const;\n readonly scenarios: readonly ScenarioNode<World>[];\n readonly scenarioOutlines: readonly ScenarioOutlineNode<World>[];\n readonly name: string;\n readonly keyword: string;\n readonly background?: SimpleScenario;\n readonly rule: SimpleRule;\n readonly scope: ScopeNode<World>;\n readonly qualifiedName: string;\n\n constructor(init: RuleNodeInit<World>) {\n this.rule = init.rule;\n this.scope = init.scope;\n this.qualifiedName = init.qualifiedName;\n this.name = init.rule.name;\n this.keyword = normalizeKeyword(init.rule.keyword ?? \"Rule\");\n if (init.rule.background) {\n this.background = init.rule.background;\n }\n this.scenarios = init.scenarios;\n this.scenarioOutlines = init.outlines;\n }\n}\n\nabstract class ScenarioExecutionBase<World, Gherkin extends SimpleScenario | SimpleCompiledScenario>\n implements ScenarioExecution<World>\n{\n readonly type: \"scenario\" | \"example\";\n readonly id: string;\n readonly name: string;\n readonly keyword: string;\n readonly qualifiedName: string;\n readonly tags: readonly string[];\n readonly mode: ExecutionMode;\n readonly pending: boolean;\n readonly pendingReason?: string;\n readonly timeout?: TimeoutSpec;\n readonly data?: Record<string, unknown>;\n readonly feature: FeatureNode<World>;\n readonly rule?: RuleNode<World>;\n readonly outline?: ScenarioOutlineNode<World>;\n readonly scope: ScopeNode<World>;\n readonly summary: ScenarioSummary<World>;\n readonly gherkin: Gherkin;\n readonly gherkinSteps: readonly SimpleStep[];\n readonly steps: readonly StepDefinition<World>[];\n readonly ancestors: readonly ScopeNode<World>[];\n\n private resultState: ScenarioResult = { status: \"pending\" };\n\n protected constructor(\n type: \"scenario\" | \"example\",\n init: ScenarioExecutionInit<World, Gherkin>\n ) {\n this.type = type;\n this.id = init.id;\n this.name = init.name;\n this.keyword = normalizeKeyword(init.keyword);\n this.qualifiedName = init.qualifiedName;\n this.tags = [...init.tags];\n this.mode = init.mode;\n this.pending = init.pending;\n if (init.pendingReason !== undefined) {\n this.pendingReason = init.pendingReason;\n }\n if (init.timeout !== undefined) {\n this.timeout = init.timeout;\n }\n const data = cloneData(init.data);\n if (data !== undefined) {\n this.data = data;\n }\n this.feature = init.feature;\n if (init.rule) {\n this.rule = init.rule;\n }\n if (init.outline) {\n this.outline = init.outline;\n }\n this.scope = init.scope;\n this.summary = init.summary;\n this.gherkin = init.gherkin;\n this.gherkinSteps = [...init.gherkinSteps];\n this.steps = [...init.steps];\n this.ancestors = [...init.ancestors];\n }\n\n get result(): ScenarioResult {\n return this.resultState;\n }\n\n markPassed(): void {\n const startedAt = this.resultState.startedAt ?? Date.now();\n this.resultState = {\n status: \"passed\",\n startedAt,\n completedAt: Date.now(),\n };\n }\n\n markFailed(error: unknown): void {\n const startedAt = this.resultState.startedAt ?? Date.now();\n this.resultState = {\n status: \"failed\",\n error: normalizeError(error),\n startedAt,\n completedAt: Date.now(),\n };\n }\n\n markSkipped(reason?: string): void {\n const timestamp = Date.now();\n this.resultState = {\n status: \"skipped\",\n startedAt: this.resultState.startedAt ?? timestamp,\n completedAt: timestamp,\n ...(reason !== undefined ? { reason } : {}),\n };\n }\n\n markPending(reason?: string): void {\n const timestamp = Date.now();\n this.resultState = {\n status: \"pending\",\n startedAt: this.resultState.startedAt ?? timestamp,\n completedAt: timestamp,\n ...(reason !== undefined ? { reason } : {}),\n };\n }\n\n reset(): void {\n this.resultState = { status: \"pending\" };\n }\n}\n\nclass ScenarioNodeImpl<World>\n extends ScenarioExecutionBase<World, SimpleScenario>\n implements ScenarioNode<World>\n{\n constructor(init: ScenarioExecutionInit<World, SimpleScenario>) {\n super(\"scenario\", init);\n }\n}\n\nclass ScenarioOutlineExampleImpl<World>\n extends ScenarioExecutionBase<World, SimpleCompiledScenario>\n implements ScenarioOutlineExample<World>\n{\n readonly outline: ScenarioOutlineNode<World>;\n readonly exampleGroup: SimpleExampleGroup;\n readonly compiled: SimpleCompiledScenario;\n readonly exampleIndex: number;\n\n constructor(init: ScenarioOutlineExampleInit<World>) {\n super(\"example\", init);\n this.outline = init.outline;\n this.exampleGroup = init.exampleGroup;\n this.compiled = init.gherkin;\n this.exampleIndex = init.exampleIndex;\n }\n}\n\nclass ScenarioOutlineNodeImpl<World>\n implements ScenarioOutlineNode<World>\n{\n readonly type = \"scenarioOutline\" as const;\n readonly outline: SimpleScenarioOutline;\n readonly summary: ScenarioSummary<World>;\n readonly scope: ScopeNode<World>;\n readonly keyword: string;\n readonly name: string;\n readonly qualifiedName: string;\n readonly tags: readonly string[];\n readonly mode: ExecutionMode;\n readonly pending: boolean;\n readonly pendingReason?: string;\n readonly timeout?: TimeoutSpec;\n readonly data?: Record<string, unknown>;\n readonly ancestors: readonly ScopeNode<World>[];\n private readonly mutableExamples: ScenarioOutlineExample<World>[];\n readonly rule?: RuleNode<World>;\n readonly feature: FeatureNode<World>;\n\n constructor(init: ScenarioOutlineNodeInit<World>) {\n this.outline = init.outline;\n this.summary = init.summary;\n this.scope = init.scope;\n this.keyword = normalizeKeyword(init.keyword);\n this.name = init.name;\n this.qualifiedName = init.qualifiedName;\n this.tags = [...init.tags];\n this.mode = init.mode;\n this.pending = init.pending;\n if (init.pendingReason !== undefined) {\n this.pendingReason = init.pendingReason;\n }\n if (init.timeout !== undefined) {\n this.timeout = init.timeout;\n }\n const data = cloneData(init.data);\n if (data !== undefined) {\n this.data = data;\n }\n this.ancestors = [...init.ancestors];\n if (init.rule) {\n this.rule = init.rule;\n }\n this.feature = init.feature;\n this.mutableExamples = init.examples;\n }\n\n get examples(): readonly ScenarioOutlineExample<World>[] {\n return this.mutableExamples;\n }\n}\n","import type { ScenarioSummary } from \"@autometa/scopes\";\nimport { normalizeName } from \"./utils\";\n\nexport type ScenarioKindKey = \"scenario\" | \"scenarioOutline\";\n\nexport type ScenarioSummaryBuckets<World> = Map<string, ScenarioSummary<World>[]>;\n\nexport function bucketScenarioSummaries<World>(\n summaries: readonly ScenarioSummary<World>[]\n): ScenarioSummaryBuckets<World> {\n const buckets: ScenarioSummaryBuckets<World> = new Map();\n\n for (const summary of summaries) {\n const key = createSummaryKey(\n summary.scenario.kind as ScenarioKindKey,\n summary.scenario.name,\n summary.rule?.id\n );\n const existing = buckets.get(key) ?? [];\n existing.push(summary);\n buckets.set(key, existing);\n }\n\n return buckets;\n}\n\nexport function createSummaryKey(\n kind: ScenarioKindKey,\n scenarioName: string,\n parentScopeId: string | undefined\n): string {\n return [\n kind,\n normalizeName(scenarioName),\n parentScopeId ?? \"root\",\n ].join(\"::\");\n}\n\nexport function describeSummary<World>(summary: ScenarioSummary<World>): string {\n const parts = [summary.scenario.name];\n if (summary.rule) {\n parts.push(`in rule '${summary.rule.name}'`);\n }\n return `${summary.scenario.kind} '${parts.join(\" \")}'`;\n}\n","import type { ScopeExecutionAdapter, ScopeNode } from \"@autometa/scopes\";\nimport type { SimpleFeature } from \"@autometa/gherkin\";\nimport { normalizeName, normalizeUri } from \"./utils\";\n\nexport function resolveFeatureScope<World>(\n adapter: ScopeExecutionAdapter<World>,\n feature: SimpleFeature\n): ScopeNode<World> {\n const normalizedName = normalizeName(feature.name);\n const featureUri = feature.uri ? normalizeUri(feature.uri) : undefined;\n\n const matches = adapter.features.filter((scope) => {\n if (scope.kind !== \"feature\") {\n return false;\n }\n\n const scopeName = normalizeName(scope.name);\n if (scopeName !== normalizedName) {\n return false;\n }\n\n if (!featureUri) {\n return true;\n }\n\n const scopeFile = typeof scope.data?.file === \"string\" ? normalizeUri(scope.data.file) : undefined;\n return scopeFile ? scopeFile === featureUri : true;\n });\n\n if (matches.length === 1) {\n const [match] = matches;\n if (!match) {\n throw new Error(\"Unexpected empty feature scope match\");\n }\n return match;\n }\n\n if (matches.length === 0) {\n throw new Error(\n `No feature scope registered for feature '${feature.name}'. Provide featureScope explicitly to resolve the association.`\n );\n }\n\n throw new Error(\n `Multiple feature scopes match feature '${feature.name}'. Provide featureScope explicitly to disambiguate.`\n );\n}\n\nexport function findChildScope<World>(\n parent: ScopeNode<World>,\n kind: ScopeNode<World>[\"kind\"],\n name: string\n): ScopeNode<World> {\n const normalizedName = normalizeName(name);\n const matches = parent.children.filter(\n (child) => child.kind === kind && normalizeName(child.name) === normalizedName\n );\n\n if (matches.length === 1) {\n const [match] = matches;\n if (!match) {\n throw new Error(\"Unexpected empty child scope match\");\n }\n return match;\n }\n\n if (matches.length === 0) {\n throw new Error(\n `Could not find ${kind} scope named '${name}' beneath '${parent.name}'`\n );\n }\n\n throw new Error(\n `Multiple ${kind} scopes named '${name}' were found beneath '${parent.name}'. Names must be unique within the same parent scope.`\n );\n}\n","import type { ScopeExecutionAdapter } from \"@autometa/scopes\";\nimport type { SimpleFeature } from \"@autometa/gherkin\";\nimport type { BuildTestPlanOptions, TestPlan } from \"./types\";\nimport { TestPlanBuilder } from \"./internal/test-plan-builder\";\nimport { resolveFeatureScope } from \"./internal/scope-resolution\";\n\nexport function buildTestPlan<World>(options: BuildTestPlanOptions<World>): TestPlan<World> {\n const { feature, adapter } = options;\n assertFeature(feature);\n assertAdapter(adapter);\n\n const featureScope =\n options.featureScope ?? resolveFeatureScope(adapter, feature);\n\n return new TestPlanBuilder(feature, featureScope, adapter).build();\n}\n\nfunction assertFeature(feature: SimpleFeature | undefined): asserts feature is SimpleFeature {\n if (!feature) {\n throw new Error(\"A Gherkin feature is required to build a test plan\");\n }\n}\n\nfunction assertAdapter<World>(\n adapter: ScopeExecutionAdapter<World> | undefined\n): asserts adapter is ScopeExecutionAdapter<World> {\n if (!adapter) {\n throw new Error(\"A scope execution adapter is required to build a test plan\");\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,161 +1,2 @@
1
- import * as _autometa_app from '@autometa/app';
2
- import { App } from '@autometa/app';
3
- import { GherkinNode, Feature, Background, Rule, Scenario, Example, ScenarioOutline, Examples, Step, DataTable, StepType, StepKeyword } from '@autometa/gherkin';
4
- import * as _autometa_scopes from '@autometa/scopes';
5
- import { Scope, GlobalScope, FeatureScope, BackgroundScope, RuleScope, ScenarioScope, ScenarioOutlineScope, StepScope } from '@autometa/scopes';
6
-
7
- declare abstract class GherkinCodeBridge {
8
- abstract data: {
9
- gherkin: GherkinNode;
10
- scope: Scope;
11
- };
12
- }
13
- declare class GlobalBridge extends GherkinCodeBridge {
14
- readonly data: {
15
- gherkin: GherkinNode;
16
- scope: GlobalScope;
17
- };
18
- constructor(scope: GlobalScope);
19
- }
20
- declare class FeatureBridge extends GherkinCodeBridge {
21
- data: {
22
- gherkin: Feature;
23
- scope: FeatureScope;
24
- };
25
- background: BackgroundBridge;
26
- scenarios: (ScenarioBridge | ScenarioOutlineBridge)[];
27
- rules: RuleBridge[];
28
- steps: StepBridge[];
29
- accumulateTags(): string[];
30
- }
31
- declare class BackgroundBridge extends GherkinCodeBridge {
32
- data: {
33
- gherkin: Background;
34
- scope: BackgroundScope;
35
- };
36
- steps: StepBridge[];
37
- }
38
- declare class RuleBridge extends GherkinCodeBridge {
39
- data: {
40
- gherkin: Rule;
41
- scope: RuleScope;
42
- };
43
- background: BackgroundBridge;
44
- scenarios: (ScenarioBridge | ScenarioOutlineBridge)[];
45
- steps: StepBridge[];
46
- accumulateTags(): string[];
47
- }
48
- declare class ScenarioBridge extends GherkinCodeBridge {
49
- data: {
50
- gherkin: Scenario;
51
- scope: ScenarioScope;
52
- };
53
- steps: StepBridge[];
54
- report: {
55
- passed?: boolean;
56
- error?: Error;
57
- };
58
- get title(): string;
59
- get tags(): string[];
60
- accumulateTags(): string[];
61
- }
62
- declare class ExampleBridge extends GherkinCodeBridge {
63
- data: {
64
- gherkin: Example;
65
- scope: ScenarioScope;
66
- };
67
- steps: StepBridge[];
68
- report: {
69
- passed?: boolean;
70
- error?: Error;
71
- };
72
- get title(): string;
73
- get tags(): string[];
74
- accumulateTags(): string[];
75
- }
76
- declare class ScenarioOutlineBridge extends GherkinCodeBridge {
77
- data: {
78
- gherkin: ScenarioOutline;
79
- scope: ScenarioOutlineScope;
80
- };
81
- examples: ExamplesBridge[];
82
- steps: StepBridge[];
83
- get title(): string;
84
- get tags(): string[];
85
- accumulateTags(): string[];
86
- }
87
- declare class ExamplesBridge extends GherkinCodeBridge {
88
- data: {
89
- gherkin: Examples;
90
- scope: ScenarioOutlineScope;
91
- };
92
- scenarios: ScenarioBridge[];
93
- steps: StepBridge[];
94
- get title(): string;
95
- get tags(): string[];
96
- accumulateTags(): string[];
97
- }
98
- declare class StepBridge extends GherkinCodeBridge {
99
- data: {
100
- gherkin: Step;
101
- scope: StepScope<string, DataTable | undefined>;
102
- args: undefined | ((app: App) => unknown[]);
103
- };
104
- get args(): ((app: App) => unknown[]) | undefined;
105
- get expressionText(): string;
106
- }
107
-
108
- declare function find(bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge, testName: string): GherkinCodeBridge | undefined;
109
- declare function findTestTypes(scenarios: (ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge)[], testName: string, from?: string): ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge | undefined;
110
- declare function findRuleTypes(rules: RuleBridge[], testName: string, from?: string): ScenarioBridge | ScenarioOutlineBridge | RuleBridge | ExamplesBridge | undefined;
111
- declare function findRuleOrChild(rule: RuleBridge, testName: string, from?: string): ScenarioBridge | ScenarioOutlineBridge | RuleBridge | ExamplesBridge | undefined;
112
- declare function findScenarioOutlineOrChild(outline: ScenarioOutlineBridge, testName: string, from?: string): ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge | undefined;
113
- declare function findExamplesOrChild(example: ExamplesBridge, testName: string, from?: string): ScenarioBridge | ExamplesBridge | undefined;
114
- declare function findScenario(scenario: ScenarioBridge, testName: string, from?: string): ScenarioBridge | undefined;
115
-
116
- declare function failed(bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge): ScenarioBridge[];
117
- declare function gherkinToTestNames(node: GherkinNode, path?: string, accumulator?: string[]): string[] | undefined;
118
- declare const Query: {
119
- find: {
120
- failed: typeof failed;
121
- };
122
- testNames: typeof gherkinToTestNames;
123
- };
124
-
125
- declare class TestBuilder {
126
- readonly feature: Feature;
127
- constructor(feature: Feature);
128
- onFeatureExecuted(featureScope: FeatureScope): FeatureBridge;
129
- }
130
-
131
- declare function scope(value: Scope): {
132
- findRule: (name: string) => RuleScope;
133
- findScenario: (name: string) => ScenarioScope;
134
- findBackground: ({ name }: {
135
- name?: string | undefined;
136
- }) => BackgroundScope;
137
- findScenarioOutline: (name: string) => ScenarioOutlineScope;
138
- findExample(name: string): ScenarioScope;
139
- findStep: (keywordType: StepType, keyword: StepKeyword, name: string) => {
140
- step: _autometa_scopes.CachedStep;
141
- args: ((app: _autometa_app.App) => unknown[]) | undefined;
142
- };
143
- };
144
-
145
- type WalkFunction<T extends GherkinNode, TAccumulator, TReturn> = (node: T, accumulator: TAccumulator, lastNode?: GherkinNode) => TReturn;
146
- type WalkFunctionMap<TAccumulator> = {
147
- onFeature?: WalkFunction<Feature, TAccumulator, TAccumulator>;
148
- onRule?: WalkFunction<Rule, TAccumulator, TAccumulator>;
149
- onBackground?: WalkFunction<Background, TAccumulator, TAccumulator>;
150
- onScenario?: WalkFunction<Scenario, TAccumulator, TAccumulator>;
151
- onScenarioOutline?: WalkFunction<ScenarioOutline, TAccumulator, TAccumulator>;
152
- onExamples?: WalkFunction<Examples, TAccumulator, TAccumulator>;
153
- onExample?: WalkFunction<Example, TAccumulator, TAccumulator>;
154
- onStep?: WalkFunction<Step, TAccumulator, TAccumulator>;
155
- };
156
- declare class GherkinWalker {
157
- #private;
158
- static walk<TAccumulator>(walkFunction: WalkFunctionMap<TAccumulator>, childNode: GherkinNode, accumulator: TAccumulator, parentNode?: GherkinNode): TAccumulator & ({} | null);
159
- }
160
-
161
- export { BackgroundBridge, ExampleBridge, ExamplesBridge, FeatureBridge, GherkinCodeBridge, GherkinWalker, GlobalBridge, Query, RuleBridge, ScenarioBridge, ScenarioOutlineBridge, StepBridge, TestBuilder, WalkFunction, WalkFunctionMap, find, findExamplesOrChild, findRuleOrChild, findRuleTypes, findScenario, findScenarioOutlineOrChild, findTestTypes, scope };
1
+ export { buildTestPlan } from "./build-test-plan";
2
+ export * from "./types";