@autometa/test-builder 0.2.12 → 0.2.13
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/.turbo/turbo-coverage.log +36 -0
- package/.turbo/turbo-lint$colon$fix.log +4 -0
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-lint:fix.log +4 -0
- package/.turbo/turbo-prettify.log +6 -0
- package/.turbo/turbo-test.log +10 -0
- package/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/dist/esm/index.js +2 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/tsup.config.ts +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
> @autometa/test-builder@0.1.1 coverage /Users/ben.aherne/Documents/GitHub/autometa/packages/test-builder
|
|
3
|
+
> vitest run --coverage
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
RUN v0.33.0 /Users/ben.aherne/Documents/GitHub/autometa/packages/test-builder
|
|
7
|
+
Coverage enabled with istanbul
|
|
8
|
+
|
|
9
|
+
✓ src/bridges/bridge-query.spec.ts (1 test) 17ms
|
|
10
|
+
✓ src/gherkin-walker.spec.ts (1 test) 17ms
|
|
11
|
+
✓ src/scope-search.spec.ts (12 tests) 14ms
|
|
12
|
+
stdout | src/bridges/bridge-search.spec.ts > Bridge Search > findRuleType > should find a rule by name
|
|
13
|
+
My Rule
|
|
14
|
+
|
|
15
|
+
✓ src/bridges/bridge-search.spec.ts (18 tests) 32ms
|
|
16
|
+
✓ src/test-builder.spec.ts (12 tests) 49ms
|
|
17
|
+
|
|
18
|
+
Test Files 5 passed (5)
|
|
19
|
+
Tests 44 passed (44)
|
|
20
|
+
Start at 16:39:00
|
|
21
|
+
Duration 4.30s (transform 2.50s, setup 0ms, collect 13.02s, tests 129ms, environment 1ms, prepare 5.18s)
|
|
22
|
+
|
|
23
|
+
% Coverage report from istanbul
|
|
24
|
+
-------------------|---------|----------|---------|---------|-------------------
|
|
25
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
26
|
+
-------------------|---------|----------|---------|---------|-------------------
|
|
27
|
+
All files | 80.5 | 66.18 | 91.11 | 80.5 |
|
|
28
|
+
src | 92.59 | 86.79 | 100 | 92.59 |
|
|
29
|
+
...kin-walker.ts | 96.66 | 90.9 | 100 | 96.66 | 39
|
|
30
|
+
scope-search.ts | 90.24 | 91.3 | 100 | 90.24 | 58,66-73
|
|
31
|
+
test-builder.ts | 92.18 | 62.5 | 100 | 92.18 | 79,136,166-168
|
|
32
|
+
src/bridges | 69.01 | 53.48 | 80.95 | 69.01 |
|
|
33
|
+
bridge-query.ts | 28.94 | 42.85 | 25 | 28.94 | 12-53,62,68
|
|
34
|
+
bridge-search.ts | 79.51 | 58.62 | 90 | 79.51 | ...5-52,69-71,111
|
|
35
|
+
bridge.ts | 100 | 100 | 100 | 100 |
|
|
36
|
+
-------------------|---------|----------|---------|---------|-------------------
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
> @autometa/test-builder@0.2.12 prettify /Users/ben.aherne/Documents/GitHub/autometa/packages/test-builder
|
|
3
|
+
> prettier --config .prettierrc 'src/**/*.ts' --write
|
|
4
|
+
|
|
5
|
+
[error] Invalid configuration file `src/bridges/bridge-query.spec.ts`: ENOENT: no such file or directory, open '/Users/ben.aherne/Documents/GitHub/autometa/packages/test-builder/.prettierrc'
|
|
6
|
+
ELIFECYCLE Command failed with exit code 2.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
> @autometa/test-builder@0.2.12 test /Users/ben.aherne/Documents/GitHub/autometa/packages/test-builder
|
|
3
|
+
> vitest run --passWithNoTests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
RUN v1.4.0 /Users/ben.aherne/Documents/GitHub/autometa/packages/test-builder
|
|
7
|
+
|
|
8
|
+
✓ src/bridges/bridge-query.spec.ts (1 test) 3ms
|
|
9
|
+
✓ src/gherkin-walker.spec.ts (1 test) 5ms
|
|
10
|
+
ELIFECYCLE Test failed. See above for more details.
|
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -273,9 +273,7 @@ function findScenario(scenario, testName, from) {
|
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
// src/bridges/bridge-query.ts
|
|
276
|
-
import {
|
|
277
|
-
Background as Background2
|
|
278
|
-
} from "@autometa/gherkin";
|
|
276
|
+
import { Background as Background2 } from "@autometa/gherkin";
|
|
279
277
|
function failed(bridge) {
|
|
280
278
|
const accumulator = [];
|
|
281
279
|
if (bridge instanceof ScenarioOutlineBridge) {
|
|
@@ -655,10 +653,7 @@ function getStep(accumulator, gherkin, cache, keywordType, keyword, text) {
|
|
|
655
653
|
} catch (e) {
|
|
656
654
|
const cause = e;
|
|
657
655
|
const { title } = gherkin;
|
|
658
|
-
raise(
|
|
659
|
-
`'${title}' could not find a step definition`,
|
|
660
|
-
{ cause }
|
|
661
|
-
);
|
|
656
|
+
raise(`'${title}' could not find a step definition`, { cause });
|
|
662
657
|
}
|
|
663
658
|
}
|
|
664
659
|
export {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bridges/bridge.ts","../../src/bridges/bridge-search.ts","../../src/bridges/bridge-query.ts","../../src/gherkin-walker.ts","../../src/scope-search.ts","../../src/test-builder.ts"],"sourcesContent":["import {\n Background,\n DataTable,\n Example,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step\n} from \"@autometa/gherkin\";\nimport { BackgroundScope, GlobalScope } from \"@autometa/scopes\";\nimport {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n ScenarioScope,\n Scope,\n StepScope\n} from \"@autometa/scopes\";\n\nexport abstract class GherkinCodeBridge {\n abstract data: { gherkin: GherkinNode; scope: Scope };\n}\nexport class GlobalBridge extends GherkinCodeBridge {\n readonly data: { gherkin: GherkinNode; scope: GlobalScope };\n constructor(scope: GlobalScope) {\n super();\n const nullNode = class extends GherkinNode {\n keyword = \"none\";\n };\n this.data = {\n scope,\n gherkin: new nullNode()\n };\n }\n}\nexport class FeatureBridge extends GherkinCodeBridge {\n data: { gherkin: Feature; scope: FeatureScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n rules: RuleBridge[] = [];\n steps: StepBridge[] = [];\n}\nexport class BackgroundBridge extends GherkinCodeBridge {\n data: { gherkin: Background; scope: BackgroundScope };\n steps: StepBridge[] = [];\n}\n\nexport class RuleBridge extends GherkinCodeBridge {\n data: { gherkin: Rule; scope: RuleScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n steps: StepBridge[] = [];\n}\n\nexport class ScenarioBridge extends GherkinCodeBridge {\n data: { gherkin: Scenario; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ExampleBridge extends GherkinCodeBridge {\n data: { gherkin: Example; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ScenarioOutlineBridge extends GherkinCodeBridge {\n data: { gherkin: ScenarioOutline; scope: ScenarioOutlineScope };\n examples: ExamplesBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class ExamplesBridge extends GherkinCodeBridge {\n data: { gherkin: Examples; scope: ScenarioOutlineScope };\n scenarios: ScenarioBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class StepBridge extends GherkinCodeBridge {\n data: {\n gherkin: Step;\n scope: StepScope<string, DataTable | undefined>;\n args: unknown[];\n };\n\n get args() {\n return this.data.scope.getArgs(this.data.gherkin.text);\n }\n\n get expressionText() {\n return this.data.scope.expression.source;\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport {\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n RuleBridge\n} from \"./bridge\";\n\nexport function find(\n bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n if (bridge instanceof FeatureBridge) {\n return findByFeature(bridge, testName);\n }\n if (bridge instanceof RuleBridge) {\n return findByRule(bridge, testName);\n }\n if (bridge instanceof ScenarioOutlineBridge) {\n return findScenarioOutlineOrChild(bridge, testName);\n }\n\n throw new AutomationError(`Could not find test matching ${testName}`);\n}\nfunction findByFeature(\n feature: FeatureBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = feature.data.scope.title(feature.data.gherkin);\n const byScenario = findTestTypes(feature.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleTypes(feature.rules, testName, title);\n if (byRule) {\n return byRule;\n }\n}\nfunction findByRule(\n rule: RuleBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = rule.data.scope.title(rule.data.gherkin);\n const byScenario = findTestTypes(rule.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleOrChild(rule, testName, title);\n if (byRule) {\n return byRule;\n }\n}\n\nexport function findTestTypes(\n scenarios: (ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge)[],\n testName: string,\n from?: string\n) {\n for (const scenario of scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n const found = findScenarioOutlineOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ExamplesBridge) {\n const found = findExamplesOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ScenarioBridge) {\n const found = findScenario(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n }\n}\n\nexport function findRuleTypes(\n rules: RuleBridge[],\n testName: string,\n from?: string\n) {\n for (const rule of rules) {\n const found = findRuleOrChild(rule, testName, from);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findRuleOrChild(\n rule: RuleBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = rule;\n const title = scope.title(gherkin);\n if (testName === title) {\n return rule;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return rule;\n }\n }\n const newFrom = appendPath(from, title);\n return findTestTypes(rule.scenarios, testName, newFrom);\n}\n\nexport function findScenarioOutlineOrChild(\n outline: ScenarioOutlineBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = outline;\n const title = scope.title(gherkin);\n if (testName === title) {\n return outline;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return outline;\n }\n }\n for (const example of outline.examples) {\n const newFrom = appendPath(from, title);\n const found = findExamplesOrChild(example, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nfunction appendPath(from: string | undefined, title: string) {\n return from ? `${from} ${title}` : title;\n}\n\nexport function findExamplesOrChild(\n example: ExamplesBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = example;\n const title = scope.title(gherkin);\n if (testName === title) {\n return example;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return example;\n }\n }\n for (const scenario of example.scenarios) {\n const newFrom = appendPath(from, title);\n const found = findScenario(scenario, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findScenario(\n scenario: ScenarioBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = scenario;\n const title = scope.title(gherkin);\n if (testName === title) {\n return scenario;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return scenario;\n }\n }\n}\n","import {\n Background,\n GherkinNode} from \"@autometa/gherkin\";\nimport {\n FeatureBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge\n} from \".\";\n\nfunction failed(bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n if (bridge instanceof ScenarioOutlineBridge) {\n return failedOutline(bridge);\n }\n for (const scenario of bridge.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed && scenario.report.error !== undefined) {\n accumulator.push(scenario);\n }\n }\n if (bridge instanceof FeatureBridge) {\n accumulator.push(...failedRule(bridge));\n }\n return accumulator;\n}\n\nfunction failedOutline(bridge: ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n\n for (const example of bridge.examples) {\n for (const scenario of example.scenarios) {\n if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction failedRule(bridge: FeatureBridge) {\n const accumulator: ScenarioBridge[] = [];\n for (const rule of bridge.rules) {\n for (const scenario of rule.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction gherkinToTestNames(\n node: GherkinNode,\n path = \"\",\n accumulator: string[] = []\n) {\n if (!(\"name\" in node) || node instanceof Background) {\n return;\n }\n const title = `${node.keyword}: ${node.name}`;\n const fullPath = path ? `${path} ${title}` : title;\n accumulator.push(fullPath);\n if (!node.children) {\n return;\n }\n for (const child of node.children) {\n if (!(\"name\" in child) || child instanceof Background) {\n continue;\n }\n gherkinToTestNames(child, fullPath, accumulator);\n }\n return accumulator;\n}\n\nexport const Query = {\n find: {\n failed\n },\n testNames: gherkinToTestNames\n};\n","import {\n Background,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step\n} from \"@autometa/gherkin\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { Example } from \"@autometa/gherkin\";\n\nexport type WalkFunction<T extends GherkinNode, TAccumulator, TReturn> = (\n node: T,\n accumulator: TAccumulator,\n lastNode?: GherkinNode\n) => TReturn;\n\nexport type WalkFunctionMap<TAccumulator> = {\n onFeature?: WalkFunction<Feature, TAccumulator, TAccumulator>;\n onRule?: WalkFunction<Rule, TAccumulator, TAccumulator>;\n onBackground?: WalkFunction<Background, TAccumulator, TAccumulator>;\n onScenario?: WalkFunction<Scenario, TAccumulator, TAccumulator>;\n onScenarioOutline?: WalkFunction<ScenarioOutline, TAccumulator, TAccumulator>;\n onExamples?: WalkFunction<Examples, TAccumulator, TAccumulator>;\n onExample?: WalkFunction<Example, TAccumulator, TAccumulator>;\n onStep?: WalkFunction<Step, TAccumulator, TAccumulator>;\n};\n\nexport class GherkinWalker {\n static walk<TAccumulator>(\n walkFunction: WalkFunctionMap<TAccumulator>,\n childNode: GherkinNode,\n accumulator: TAccumulator,\n parentNode?: GherkinNode\n ) {\n if (accumulator === undefined) {\n throw new AutomationError(\n `An accumulator must be defined to continue the walker from ${\n childNode.constructor.name\n }${JSON.stringify(childNode)}`\n );\n }\n this.#walkNode(childNode, accumulator, walkFunction, parentNode);\n return accumulator;\n }\n\n static #walkNode<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n walkFunction: WalkFunctionMap<TAccumulator>,\n lastNode?: GherkinNode\n ) {\n if (child instanceof Feature && walkFunction.onFeature) {\n const acc = walkFunction.onFeature(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Rule && walkFunction.onRule) {\n const acc = walkFunction.onRule(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Examples) {\n const acc = walkFunction.onExamples?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Example) {\n const acc = walkFunction.onExample?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Scenario) {\n const acc = walkFunction.onScenario?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof ScenarioOutline) {\n const acc = walkFunction.onScenarioOutline?.(\n child,\n accumulator,\n lastNode\n );\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Background) {\n const acc = walkFunction?.onBackground?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Step) {\n const acc = walkFunction.onStep?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n }\n\n static #walkChildren<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n walkFunction: WalkFunctionMap<any>\n ) {\n for (const node of child.children) {\n this.walk(walkFunction, node, accumulator, child);\n }\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport { StepKeyword } from \"@autometa/gherkin\";\nimport { StepType } from \"@autometa/gherkin\";\nimport {\n Scope,\n RuleScope,\n ScenarioScope,\n ScenarioOutlineScope,\n BackgroundScope\n} from \"@autometa/scopes\";\nimport { Empty_Function } from \"@autometa/scopes\";\n\nexport function scope(value: Scope) {\n return {\n findRule: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return child instanceof RuleScope && child.name === name;\n }) as RuleScope | undefined;\n if (!found) {\n const rule = new RuleScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(rule);\n return rule;\n }\n return found;\n },\n findScenario: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return (\n child instanceof ScenarioScope &&\n child.name === name &&\n !(child instanceof ScenarioOutlineScope)\n );\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findBackground: ({ name }: { name?: string }): BackgroundScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof BackgroundScope;\n }) as BackgroundScope | undefined;\n if (found && found.name !== name) {\n throw new AutomationError(\n `Could not find background matching ${name} but found ${found?.name}`\n );\n }\n if (found) {\n return found;\n }\n\n const bgScope = new BackgroundScope(\n name,\n Empty_Function,\n value.hooks,\n value.steps\n );\n value.attach(bgScope);\n return bgScope;\n },\n findScenarioOutline: (name: string): ScenarioOutlineScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof ScenarioOutlineScope && child.name === name;\n }) as ScenarioOutlineScope | undefined;\n if (!found) {\n const scenarioOutline = new ScenarioOutlineScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenarioOutline);\n return scenarioOutline;\n }\n return found;\n },\n findExample(name: string): ScenarioScope {\n const found = value.closedScopes.find((child) => {\n if (!(child instanceof ScenarioScope)) {\n return false;\n }\n return child.name === name;\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findStep: (keywordType: StepType, keyword: StepKeyword, name: string) => {\n return value.steps.find(keywordType, keyword, name);\n }\n };\n}\n","import {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n StepCache\n} from \"@autometa/scopes\";\nimport {\n BackgroundBridge,\n ExampleBridge,\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n StepBridge\n} from \"./bridges\";\nimport { GherkinWalker } from \"./gherkin-walker\";\nimport { scope } from \"./scope-search\";\nimport { Bind } from \"@autometa/bind-decorator\";\nimport {\n Example,\n Feature,\n GherkinNode,\n Scenario,\n scenarioExampleTitle\n} from \"@autometa/gherkin\";\nimport { raise } from \"@autometa/errors\";\nimport { StepKeyword, StepType } from \"@autometa/types\";\nexport class TestBuilder {\n constructor(readonly feature: Feature) {}\n @Bind\n onFeatureExecuted(featureScope: FeatureScope) {\n const bridge = new FeatureBridge();\n GherkinWalker.walk<GherkinCodeBridge>(\n {\n onFeature: (feature, accumulator) => {\n accumulator.data = { gherkin: feature, scope: featureScope };\n return accumulator;\n },\n onRule: (rule, accumulator) => {\n const ruleScope = scope(featureScope).findRule(\n rule.name\n ) as RuleScope;\n const bridge = new RuleBridge();\n bridge.data = { gherkin: rule, scope: ruleScope };\n (accumulator as FeatureBridge).rules.push(bridge);\n return bridge;\n },\n onScenario: (gherkin, accumulator) => {\n const scenarioScope = scope(accumulator.data.scope).findScenario(\n gherkin.name\n );\n const bridge = new ScenarioBridge();\n bridge.data = { gherkin, scope: scenarioScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n // if accumulator is a outline, push to examples\n\n return bridge;\n },\n onScenarioOutline: (gherkin, accumulator) => {\n const outlineScope = scope(\n accumulator.data.scope\n ).findScenarioOutline(gherkin.name);\n const bridge = new ScenarioOutlineBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n return bridge;\n },\n onExamples: (gherkin, accumulator) => {\n const outlineScope = accumulator.data.scope as ScenarioOutlineScope;\n const bridge = new ExamplesBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as ScenarioOutlineBridge).examples.push(bridge);\n return bridge;\n },\n onExample(gherkin, accumulator) {\n if (gherkin.table === undefined) {\n raise(\n `Example ${gherkin.name} has no Example Table data. A Row of data is required.`\n );\n }\n const titleSegments = Object.keys(gherkin.table);\n const values = Object.values(gherkin.table);\n const title = scenarioExampleTitle(\n titleSegments,\n gherkin.name,\n values\n );\n\n const exampleScope = scope(accumulator.data.scope).findExample(title);\n const bridge = new ExampleBridge();\n bridge.data = { gherkin, scope: exampleScope };\n const acc = accumulator as ExamplesBridge;\n acc.scenarios.push(bridge);\n return bridge;\n },\n onBackground(gherkin, accumulator) {\n const backgroundScope = scope(accumulator.data.scope).findBackground({\n name: gherkin.name\n });\n const bridge = new BackgroundBridge();\n bridge.data = { gherkin, scope: backgroundScope };\n const acc = accumulator as FeatureBridge | RuleBridge;\n acc.background = bridge;\n return bridge;\n },\n onStep: (step, accumulator) => {\n const {\n data: { scope: parentScope, gherkin }\n } = accumulator;\n const { keyword, keywordType, text } = step;\n const cache = parentScope.steps;\n const existing = getStep(\n accumulator,\n gherkin,\n cache,\n keywordType,\n keyword,\n text\n );\n const bridge = new StepBridge();\n const acc = accumulator as\n | BackgroundBridge\n | ScenarioBridge\n | RuleBridge\n | FeatureBridge;\n\n if (existing) {\n bridge.data = {\n gherkin: step,\n scope: existing.step,\n args: existing.args\n };\n } else {\n raise(`No step definition matching ${step.keyword} ${step.text}`);\n }\n\n acc.steps.push(bridge);\n return accumulator;\n }\n },\n this.feature,\n bridge\n );\n return bridge;\n }\n}\nfunction getStep(\n accumulator: GherkinCodeBridge,\n gherkin: GherkinNode,\n cache: StepCache,\n keywordType: StepType,\n keyword: StepKeyword,\n text: string\n) {\n try {\n if (accumulator instanceof ExampleBridge) {\n const scenario = gherkin as Example;\n if (scenario.table) {\n return cache.findByExample(keywordType, keyword, text, scenario.table);\n }\n }\n return cache.find(keywordType, keyword, text);\n } catch (e) {\n const cause = e as Error;\n const { title } = gherkin as Scenario;\n raise(\n `'${title}' could not find a step definition`,\n { cause }\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAME;AAAA,OAKK;AAWA,IAAe,oBAAf,MAAiC;AAExC;AACO,IAAM,eAAN,cAA2B,kBAAkB;AAAA,EAElD,YAAYA,QAAoB;AAC9B,UAAM;AACN,UAAM,WAAW,cAAc,YAAY;AAAA,MAA1B;AAAA;AACf,uBAAU;AAAA;AAAA,IACZ;AACA,SAAK,OAAO;AAAA,MACV,OAAAA;A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,IAAI,KAAK;AAAA,MACT,EAAE,MAAM;AAAA,IACV;AAAA,EACF;AACF;","names":["scope","scope","Background","Background","Background","Examples","Feature","Rule","Scenario","ScenarioOutline","Step","AutomationError","Example","AutomationError","Feature","Rule","Examples","Example","Scenario","ScenarioOutline","Background","Step","AutomationError","bridge"]}
|
|
1
|
+
{"version":3,"sources":["../../src/bridges/bridge.ts","../../src/bridges/bridge-search.ts","../../src/bridges/bridge-query.ts","../../src/gherkin-walker.ts","../../src/scope-search.ts","../../src/test-builder.ts"],"sourcesContent":["import {\n Background,\n DataTable,\n Example,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step,\n} from \"@autometa/gherkin\";\nimport { BackgroundScope, GlobalScope } from \"@autometa/scopes\";\nimport {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n ScenarioScope,\n Scope,\n StepScope,\n} from \"@autometa/scopes\";\n\nexport abstract class GherkinCodeBridge {\n abstract data: { gherkin: GherkinNode; scope: Scope };\n}\nexport class GlobalBridge extends GherkinCodeBridge {\n readonly data: { gherkin: GherkinNode; scope: GlobalScope };\n constructor(scope: GlobalScope) {\n super();\n const nullNode = class extends GherkinNode {\n keyword = \"none\";\n };\n this.data = {\n scope,\n gherkin: new nullNode(),\n };\n }\n}\nexport class FeatureBridge extends GherkinCodeBridge {\n data: { gherkin: Feature; scope: FeatureScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n rules: RuleBridge[] = [];\n steps: StepBridge[] = [];\n}\nexport class BackgroundBridge extends GherkinCodeBridge {\n data: { gherkin: Background; scope: BackgroundScope };\n steps: StepBridge[] = [];\n}\n\nexport class RuleBridge extends GherkinCodeBridge {\n data: { gherkin: Rule; scope: RuleScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n steps: StepBridge[] = [];\n}\n\nexport class ScenarioBridge extends GherkinCodeBridge {\n data: { gherkin: Scenario; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ExampleBridge extends GherkinCodeBridge {\n data: { gherkin: Example; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ScenarioOutlineBridge extends GherkinCodeBridge {\n data: { gherkin: ScenarioOutline; scope: ScenarioOutlineScope };\n examples: ExamplesBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class ExamplesBridge extends GherkinCodeBridge {\n data: { gherkin: Examples; scope: ScenarioOutlineScope };\n scenarios: ScenarioBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class StepBridge extends GherkinCodeBridge {\n data: {\n gherkin: Step;\n scope: StepScope<string, DataTable | undefined>;\n args: unknown[];\n };\n\n get args() {\n return this.data.scope.getArgs(this.data.gherkin.text);\n }\n\n get expressionText() {\n return this.data.scope.expression.source;\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport {\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n RuleBridge,\n} from \"./bridge\";\n\nexport function find(\n bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n if (bridge instanceof FeatureBridge) {\n return findByFeature(bridge, testName);\n }\n if (bridge instanceof RuleBridge) {\n return findByRule(bridge, testName);\n }\n if (bridge instanceof ScenarioOutlineBridge) {\n return findScenarioOutlineOrChild(bridge, testName);\n }\n\n throw new AutomationError(`Could not find test matching ${testName}`);\n}\nfunction findByFeature(\n feature: FeatureBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = feature.data.scope.title(feature.data.gherkin);\n const byScenario = findTestTypes(feature.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleTypes(feature.rules, testName, title);\n if (byRule) {\n return byRule;\n }\n}\nfunction findByRule(\n rule: RuleBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = rule.data.scope.title(rule.data.gherkin);\n const byScenario = findTestTypes(rule.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleOrChild(rule, testName, title);\n if (byRule) {\n return byRule;\n }\n}\n\nexport function findTestTypes(\n scenarios: (ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge)[],\n testName: string,\n from?: string\n) {\n for (const scenario of scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n const found = findScenarioOutlineOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ExamplesBridge) {\n const found = findExamplesOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ScenarioBridge) {\n const found = findScenario(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n }\n}\n\nexport function findRuleTypes(\n rules: RuleBridge[],\n testName: string,\n from?: string\n) {\n for (const rule of rules) {\n const found = findRuleOrChild(rule, testName, from);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findRuleOrChild(\n rule: RuleBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = rule;\n const title = scope.title(gherkin);\n if (testName === title) {\n return rule;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return rule;\n }\n }\n const newFrom = appendPath(from, title);\n return findTestTypes(rule.scenarios, testName, newFrom);\n}\n\nexport function findScenarioOutlineOrChild(\n outline: ScenarioOutlineBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = outline;\n const title = scope.title(gherkin);\n if (testName === title) {\n return outline;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return outline;\n }\n }\n for (const example of outline.examples) {\n const newFrom = appendPath(from, title);\n const found = findExamplesOrChild(example, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nfunction appendPath(from: string | undefined, title: string) {\n return from ? `${from} ${title}` : title;\n}\n\nexport function findExamplesOrChild(\n example: ExamplesBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = example;\n const title = scope.title(gherkin);\n if (testName === title) {\n return example;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return example;\n }\n }\n for (const scenario of example.scenarios) {\n const newFrom = appendPath(from, title);\n const found = findScenario(scenario, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findScenario(\n scenario: ScenarioBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = scenario;\n const title = scope.title(gherkin);\n if (testName === title) {\n return scenario;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return scenario;\n }\n }\n}\n","import { Background, GherkinNode } from \"@autometa/gherkin\";\nimport {\n FeatureBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n} from \".\";\n\nfunction failed(bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n if (bridge instanceof ScenarioOutlineBridge) {\n return failedOutline(bridge);\n }\n for (const scenario of bridge.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed && scenario.report.error !== undefined) {\n accumulator.push(scenario);\n }\n }\n if (bridge instanceof FeatureBridge) {\n accumulator.push(...failedRule(bridge));\n }\n return accumulator;\n}\n\nfunction failedOutline(bridge: ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n\n for (const example of bridge.examples) {\n for (const scenario of example.scenarios) {\n if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction failedRule(bridge: FeatureBridge) {\n const accumulator: ScenarioBridge[] = [];\n for (const rule of bridge.rules) {\n for (const scenario of rule.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction gherkinToTestNames(\n node: GherkinNode,\n path = \"\",\n accumulator: string[] = []\n) {\n if (!(\"name\" in node) || node instanceof Background) {\n return;\n }\n const title = `${node.keyword}: ${node.name}`;\n const fullPath = path ? `${path} ${title}` : title;\n accumulator.push(fullPath);\n if (!node.children) {\n return;\n }\n for (const child of node.children) {\n if (!(\"name\" in child) || child instanceof Background) {\n continue;\n }\n gherkinToTestNames(child, fullPath, accumulator);\n }\n return accumulator;\n}\n\nexport const Query = {\n find: {\n failed,\n },\n testNames: gherkinToTestNames,\n};\n","import {\n Background,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step,\n} from \"@autometa/gherkin\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { Example } from \"@autometa/gherkin\";\n\nexport type WalkFunction<T extends GherkinNode, TAccumulator, TReturn> = (\n node: T,\n accumulator: TAccumulator,\n lastNode?: GherkinNode\n) => TReturn;\n\nexport type WalkFunctionMap<TAccumulator> = {\n onFeature?: WalkFunction<Feature, TAccumulator, TAccumulator>;\n onRule?: WalkFunction<Rule, TAccumulator, TAccumulator>;\n onBackground?: WalkFunction<Background, TAccumulator, TAccumulator>;\n onScenario?: WalkFunction<Scenario, TAccumulator, TAccumulator>;\n onScenarioOutline?: WalkFunction<ScenarioOutline, TAccumulator, TAccumulator>;\n onExamples?: WalkFunction<Examples, TAccumulator, TAccumulator>;\n onExample?: WalkFunction<Example, TAccumulator, TAccumulator>;\n onStep?: WalkFunction<Step, TAccumulator, TAccumulator>;\n};\n\nexport class GherkinWalker {\n static walk<TAccumulator>(\n walkFunction: WalkFunctionMap<TAccumulator>,\n childNode: GherkinNode,\n accumulator: TAccumulator,\n parentNode?: GherkinNode\n ) {\n if (accumulator === undefined) {\n throw new AutomationError(\n `An accumulator must be defined to continue the walker from ${\n childNode.constructor.name\n }${JSON.stringify(childNode)}`\n );\n }\n this.#walkNode(childNode, accumulator, walkFunction, parentNode);\n return accumulator;\n }\n\n static #walkNode<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n walkFunction: WalkFunctionMap<TAccumulator>,\n lastNode?: GherkinNode\n ) {\n if (child instanceof Feature && walkFunction.onFeature) {\n const acc = walkFunction.onFeature(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Rule && walkFunction.onRule) {\n const acc = walkFunction.onRule(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Examples) {\n const acc = walkFunction.onExamples?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Example) {\n const acc = walkFunction.onExample?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Scenario) {\n const acc = walkFunction.onScenario?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof ScenarioOutline) {\n const acc = walkFunction.onScenarioOutline?.(\n child,\n accumulator,\n lastNode\n );\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Background) {\n const acc = walkFunction?.onBackground?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Step) {\n const acc = walkFunction.onStep?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n }\n\n static #walkChildren<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n walkFunction: WalkFunctionMap<any>\n ) {\n for (const node of child.children) {\n this.walk(walkFunction, node, accumulator, child);\n }\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport { StepKeyword } from \"@autometa/gherkin\";\nimport { StepType } from \"@autometa/gherkin\";\nimport {\n Scope,\n RuleScope,\n ScenarioScope,\n ScenarioOutlineScope,\n BackgroundScope,\n} from \"@autometa/scopes\";\nimport { Empty_Function } from \"@autometa/scopes\";\n\nexport function scope(value: Scope) {\n return {\n findRule: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return child instanceof RuleScope && child.name === name;\n }) as RuleScope | undefined;\n if (!found) {\n const rule = new RuleScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(rule);\n return rule;\n }\n return found;\n },\n findScenario: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return (\n child instanceof ScenarioScope &&\n child.name === name &&\n !(child instanceof ScenarioOutlineScope)\n );\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findBackground: ({ name }: { name?: string }): BackgroundScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof BackgroundScope;\n }) as BackgroundScope | undefined;\n if (found && found.name !== name) {\n throw new AutomationError(\n `Could not find background matching ${name} but found ${found?.name}`\n );\n }\n if (found) {\n return found;\n }\n\n const bgScope = new BackgroundScope(\n name,\n Empty_Function,\n value.hooks,\n value.steps\n );\n value.attach(bgScope);\n return bgScope;\n },\n findScenarioOutline: (name: string): ScenarioOutlineScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof ScenarioOutlineScope && child.name === name;\n }) as ScenarioOutlineScope | undefined;\n if (!found) {\n const scenarioOutline = new ScenarioOutlineScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenarioOutline);\n return scenarioOutline;\n }\n return found;\n },\n findExample(name: string): ScenarioScope {\n const found = value.closedScopes.find((child) => {\n if (!(child instanceof ScenarioScope)) {\n return false;\n }\n return child.name === name;\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findStep: (keywordType: StepType, keyword: StepKeyword, name: string) => {\n return value.steps.find(keywordType, keyword, name);\n },\n };\n}\n","import {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n StepCache,\n} from \"@autometa/scopes\";\nimport {\n BackgroundBridge,\n ExampleBridge,\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n StepBridge,\n} from \"./bridges\";\nimport { GherkinWalker } from \"./gherkin-walker\";\nimport { scope } from \"./scope-search\";\nimport { Bind } from \"@autometa/bind-decorator\";\nimport {\n Example,\n Feature,\n GherkinNode,\n Scenario,\n scenarioExampleTitle,\n} from \"@autometa/gherkin\";\nimport { raise } from \"@autometa/errors\";\nimport { StepKeyword, StepType } from \"@autometa/types\";\nexport class TestBuilder {\n constructor(readonly feature: Feature) {}\n @Bind\n onFeatureExecuted(featureScope: FeatureScope) {\n const bridge = new FeatureBridge();\n GherkinWalker.walk<GherkinCodeBridge>(\n {\n onFeature: (feature, accumulator) => {\n accumulator.data = { gherkin: feature, scope: featureScope };\n return accumulator;\n },\n onRule: (rule, accumulator) => {\n const ruleScope = scope(featureScope).findRule(\n rule.name\n ) as RuleScope;\n const bridge = new RuleBridge();\n bridge.data = { gherkin: rule, scope: ruleScope };\n (accumulator as FeatureBridge).rules.push(bridge);\n return bridge;\n },\n onScenario: (gherkin, accumulator) => {\n const scenarioScope = scope(accumulator.data.scope).findScenario(\n gherkin.name\n );\n const bridge = new ScenarioBridge();\n bridge.data = { gherkin, scope: scenarioScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n // if accumulator is a outline, push to examples\n\n return bridge;\n },\n onScenarioOutline: (gherkin, accumulator) => {\n const outlineScope = scope(\n accumulator.data.scope\n ).findScenarioOutline(gherkin.name);\n const bridge = new ScenarioOutlineBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n return bridge;\n },\n onExamples: (gherkin, accumulator) => {\n const outlineScope = accumulator.data.scope as ScenarioOutlineScope;\n const bridge = new ExamplesBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as ScenarioOutlineBridge).examples.push(bridge);\n return bridge;\n },\n onExample(gherkin, accumulator) {\n if (gherkin.table === undefined) {\n raise(\n `Example ${gherkin.name} has no Example Table data. A Row of data is required.`\n );\n }\n const titleSegments = Object.keys(gherkin.table);\n const values = Object.values(gherkin.table);\n const title = scenarioExampleTitle(\n titleSegments,\n gherkin.name,\n values\n );\n\n const exampleScope = scope(accumulator.data.scope).findExample(title);\n const bridge = new ExampleBridge();\n bridge.data = { gherkin, scope: exampleScope };\n const acc = accumulator as ExamplesBridge;\n acc.scenarios.push(bridge);\n return bridge;\n },\n onBackground(gherkin, accumulator) {\n const backgroundScope = scope(accumulator.data.scope).findBackground({\n name: gherkin.name,\n });\n const bridge = new BackgroundBridge();\n bridge.data = { gherkin, scope: backgroundScope };\n const acc = accumulator as FeatureBridge | RuleBridge;\n acc.background = bridge;\n return bridge;\n },\n onStep: (step, accumulator) => {\n const {\n data: { scope: parentScope, gherkin },\n } = accumulator;\n const { keyword, keywordType, text } = step;\n const cache = parentScope.steps;\n const existing = getStep(\n accumulator,\n gherkin,\n cache,\n keywordType,\n keyword,\n text\n );\n const bridge = new StepBridge();\n const acc = accumulator as\n | BackgroundBridge\n | ScenarioBridge\n | RuleBridge\n | FeatureBridge;\n\n if (existing) {\n bridge.data = {\n gherkin: step,\n scope: existing.step,\n args: existing.args,\n };\n } else {\n raise(`No step definition matching ${step.keyword} ${step.text}`);\n }\n\n acc.steps.push(bridge);\n return accumulator;\n },\n },\n this.feature,\n bridge\n );\n return bridge;\n }\n}\nfunction getStep(\n accumulator: GherkinCodeBridge,\n gherkin: GherkinNode,\n cache: StepCache,\n keywordType: StepType,\n keyword: StepKeyword,\n text: string\n) {\n try {\n if (accumulator instanceof ExampleBridge) {\n const scenario = gherkin as Example;\n if (scenario.table) {\n return cache.findByExample(keywordType, keyword, text, scenario.table);\n }\n }\n return cache.find(keywordType, keyword, text);\n } catch (e) {\n const cause = e as Error;\n const { title } = gherkin as Scenario;\n raise(`'${title}' could not find a step definition`, { cause });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAME;AAAA,OAKK;AAWA,IAAe,oBAAf,MAAiC;AAExC;AACO,IAAM,eAAN,cAA2B,kBAAkB;AAAA,EAElD,YAAYA,QAAoB;AAC9B,UAAM;AACN,UAAM,WAAW,cAAc,YAAY;AAAA,MAA1B;AAAA;AACf,uBAAU;AAAA;AAAA,IACZ;AACA,SAAK,OAAO;AAAA,MACV,OAAAA;AAAA,MACA,SAAS,IAAI,SAAS;AAAA,IACxB;AAAA,EACF;AACF;AACO,IAAM,gBAAN,cAA4B,kBAAkB;AAAA,EAA9C;AAAA;AAGL,qBAAwD,CAAC;AACzD,iBAAsB,CAAC;AACvB,iBAAsB,CAAC;AAAA;AACzB;AACO,IAAM,mBAAN,cAA+B,kBAAkB;AAAA,EAAjD;AAAA;AAEL,iBAAsB,CAAC;AAAA;AACzB;AAEO,IAAM,aAAN,cAAyB,kBAAkB;AAAA,EAA3C;AAAA;AAGL,qBAAwD,CAAC;AACzD,iBAAsB,CAAC;AAAA;AACzB;AAEO,IAAM,iBAAN,cAA6B,kBAAkB;AAAA,EAA/C;AAAA;AAEL,iBAAsB,CAAC;AACvB,kBAGI,CAAC;AAAA;AAAA,EAEL,IAAI,QAAQ;AACV,WAAO,KAAK,KAAK,MAAM,MAAM,KAAK,KAAK,OAAO;AAAA,EAChD;AAAA,EACA,IAAI,OAAO;AACT,WAAO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O,SAAS;AAAA,cAChB,MAAM,SAAS;AAAA,YACjB;AAAA,UACF,OAAO;AACL,kBAAM,+BAA+B,KAAK,OAAO,IAAI,KAAK,IAAI,EAAE;AAAA,UAClE;AAEA,cAAI,MAAM,KAAKA,OAAM;AACrB,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,KAAK;AAAA,MACL;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAnHE;AAAA,EADC;AAAA,GAFU,YAGX;AAoHF,SAAS,QACP,aACA,SACA,OACA,aACA,SACA,MACA;AACA,MAAI;AACF,QAAI,uBAAuB,eAAe;AACxC,YAAM,WAAW;AACjB,UAAI,SAAS,OAAO;AAClB,eAAO,MAAM,cAAc,aAAa,SAAS,MAAM,SAAS,KAAK;AAAA,MACvE;AAAA,IACF;AACA,WAAO,MAAM,KAAK,aAAa,SAAS,IAAI;AAAA,EAC9C,SAAS,GAAG;AACV,UAAM,QAAQ;AACd,UAAM,EAAE,MAAM,IAAI;AAClB,UAAM,IAAI,KAAK,sCAAsC,EAAE,MAAM,CAAC;AAAA,EAChE;AACF;","names":["scope","scope","Background","Background","Background","Examples","Feature","Rule","Scenario","ScenarioOutline","Step","AutomationError","Example","AutomationError","Feature","Rule","Examples","Example","Scenario","ScenarioOutline","Background","Step","AutomationError","bridge"]}
|
package/dist/index.js
CHANGED
|
@@ -679,10 +679,7 @@ function getStep(accumulator, gherkin, cache, keywordType, keyword, text) {
|
|
|
679
679
|
} catch (e) {
|
|
680
680
|
const cause = e;
|
|
681
681
|
const { title } = gherkin;
|
|
682
|
-
(0, import_errors4.raise)(
|
|
683
|
-
`'${title}' could not find a step definition`,
|
|
684
|
-
{ cause }
|
|
685
|
-
);
|
|
682
|
+
(0, import_errors4.raise)(`'${title}' could not find a step definition`, { cause });
|
|
686
683
|
}
|
|
687
684
|
}
|
|
688
685
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/bridges/bridge.ts","../src/bridges/bridge-search.ts","../src/bridges/bridge-query.ts","../src/gherkin-walker.ts","../src/scope-search.ts","../src/test-builder.ts"],"sourcesContent":["export * from './bridges'\nexport * from './test-builder'\nexport * from './scope-search'\nexport * from './gherkin-walker'","import {\n Background,\n DataTable,\n Example,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step\n} from \"@autometa/gherkin\";\nimport { BackgroundScope, GlobalScope } from \"@autometa/scopes\";\nimport {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n ScenarioScope,\n Scope,\n StepScope\n} from \"@autometa/scopes\";\n\nexport abstract class GherkinCodeBridge {\n abstract data: { gherkin: GherkinNode; scope: Scope };\n}\nexport class GlobalBridge extends GherkinCodeBridge {\n readonly data: { gherkin: GherkinNode; scope: GlobalScope };\n constructor(scope: GlobalScope) {\n super();\n const nullNode = class extends GherkinNode {\n keyword = \"none\";\n };\n this.data = {\n scope,\n gherkin: new nullNode()\n };\n }\n}\nexport class FeatureBridge extends GherkinCodeBridge {\n data: { gherkin: Feature; scope: FeatureScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n rules: RuleBridge[] = [];\n steps: StepBridge[] = [];\n}\nexport class BackgroundBridge extends GherkinCodeBridge {\n data: { gherkin: Background; scope: BackgroundScope };\n steps: StepBridge[] = [];\n}\n\nexport class RuleBridge extends GherkinCodeBridge {\n data: { gherkin: Rule; scope: RuleScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n steps: StepBridge[] = [];\n}\n\nexport class ScenarioBridge extends GherkinCodeBridge {\n data: { gherkin: Scenario; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ExampleBridge extends GherkinCodeBridge {\n data: { gherkin: Example; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ScenarioOutlineBridge extends GherkinCodeBridge {\n data: { gherkin: ScenarioOutline; scope: ScenarioOutlineScope };\n examples: ExamplesBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class ExamplesBridge extends GherkinCodeBridge {\n data: { gherkin: Examples; scope: ScenarioOutlineScope };\n scenarios: ScenarioBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class StepBridge extends GherkinCodeBridge {\n data: {\n gherkin: Step;\n scope: StepScope<string, DataTable | undefined>;\n args: unknown[];\n };\n\n get args() {\n return this.data.scope.getArgs(this.data.gherkin.text);\n }\n\n get expressionText() {\n return this.data.scope.expression.source;\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport {\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n RuleBridge\n} from \"./bridge\";\n\nexport function find(\n bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n if (bridge instanceof FeatureBridge) {\n return findByFeature(bridge, testName);\n }\n if (bridge instanceof RuleBridge) {\n return findByRule(bridge, testName);\n }\n if (bridge instanceof ScenarioOutlineBridge) {\n return findScenarioOutlineOrChild(bridge, testName);\n }\n\n throw new AutomationError(`Could not find test matching ${testName}`);\n}\nfunction findByFeature(\n feature: FeatureBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = feature.data.scope.title(feature.data.gherkin);\n const byScenario = findTestTypes(feature.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleTypes(feature.rules, testName, title);\n if (byRule) {\n return byRule;\n }\n}\nfunction findByRule(\n rule: RuleBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = rule.data.scope.title(rule.data.gherkin);\n const byScenario = findTestTypes(rule.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleOrChild(rule, testName, title);\n if (byRule) {\n return byRule;\n }\n}\n\nexport function findTestTypes(\n scenarios: (ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge)[],\n testName: string,\n from?: string\n) {\n for (const scenario of scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n const found = findScenarioOutlineOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ExamplesBridge) {\n const found = findExamplesOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ScenarioBridge) {\n const found = findScenario(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n }\n}\n\nexport function findRuleTypes(\n rules: RuleBridge[],\n testName: string,\n from?: string\n) {\n for (const rule of rules) {\n const found = findRuleOrChild(rule, testName, from);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findRuleOrChild(\n rule: RuleBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = rule;\n const title = scope.title(gherkin);\n if (testName === title) {\n return rule;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return rule;\n }\n }\n const newFrom = appendPath(from, title);\n return findTestTypes(rule.scenarios, testName, newFrom);\n}\n\nexport function findScenarioOutlineOrChild(\n outline: ScenarioOutlineBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = outline;\n const title = scope.title(gherkin);\n if (testName === title) {\n return outline;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return outline;\n }\n }\n for (const example of outline.examples) {\n const newFrom = appendPath(from, title);\n const found = findExamplesOrChild(example, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nfunction appendPath(from: string | undefined, title: string) {\n return from ? `${from} ${title}` : title;\n}\n\nexport function findExamplesOrChild(\n example: ExamplesBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = example;\n const title = scope.title(gherkin);\n if (testName === title) {\n return example;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return example;\n }\n }\n for (const scenario of example.scenarios) {\n const newFrom = appendPath(from, title);\n const found = findScenario(scenario, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findScenario(\n scenario: ScenarioBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin }\n } = scenario;\n const title = scope.title(gherkin);\n if (testName === title) {\n return scenario;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return scenario;\n }\n }\n}\n","import {\n Background,\n GherkinNode} from \"@autometa/gherkin\";\nimport {\n FeatureBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge\n} from \".\";\n\nfunction failed(bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n if (bridge instanceof ScenarioOutlineBridge) {\n return failedOutline(bridge);\n }\n for (const scenario of bridge.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed && scenario.report.error !== undefined) {\n accumulator.push(scenario);\n }\n }\n if (bridge instanceof FeatureBridge) {\n accumulator.push(...failedRule(bridge));\n }\n return accumulator;\n}\n\nfunction failedOutline(bridge: ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n\n for (const example of bridge.examples) {\n for (const scenario of example.scenarios) {\n if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction failedRule(bridge: FeatureBridge) {\n const accumulator: ScenarioBridge[] = [];\n for (const rule of bridge.rules) {\n for (const scenario of rule.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction gherkinToTestNames(\n node: GherkinNode,\n path = \"\",\n accumulator: string[] = []\n) {\n if (!(\"name\" in node) || node instanceof Background) {\n return;\n }\n const title = `${node.keyword}: ${node.name}`;\n const fullPath = path ? `${path} ${title}` : title;\n accumulator.push(fullPath);\n if (!node.children) {\n return;\n }\n for (const child of node.children) {\n if (!(\"name\" in child) || child instanceof Background) {\n continue;\n }\n gherkinToTestNames(child, fullPath, accumulator);\n }\n return accumulator;\n}\n\nexport const Query = {\n find: {\n failed\n },\n testNames: gherkinToTestNames\n};\n","import {\n Background,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step\n} from \"@autometa/gherkin\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { Example } from \"@autometa/gherkin\";\n\nexport type WalkFunction<T extends GherkinNode, TAccumulator, TReturn> = (\n node: T,\n accumulator: TAccumulator,\n lastNode?: GherkinNode\n) => TReturn;\n\nexport type WalkFunctionMap<TAccumulator> = {\n onFeature?: WalkFunction<Feature, TAccumulator, TAccumulator>;\n onRule?: WalkFunction<Rule, TAccumulator, TAccumulator>;\n onBackground?: WalkFunction<Background, TAccumulator, TAccumulator>;\n onScenario?: WalkFunction<Scenario, TAccumulator, TAccumulator>;\n onScenarioOutline?: WalkFunction<ScenarioOutline, TAccumulator, TAccumulator>;\n onExamples?: WalkFunction<Examples, TAccumulator, TAccumulator>;\n onExample?: WalkFunction<Example, TAccumulator, TAccumulator>;\n onStep?: WalkFunction<Step, TAccumulator, TAccumulator>;\n};\n\nexport class GherkinWalker {\n static walk<TAccumulator>(\n walkFunction: WalkFunctionMap<TAccumulator>,\n childNode: GherkinNode,\n accumulator: TAccumulator,\n parentNode?: GherkinNode\n ) {\n if (accumulator === undefined) {\n throw new AutomationError(\n `An accumulator must be defined to continue the walker from ${\n childNode.constructor.name\n }${JSON.stringify(childNode)}`\n );\n }\n this.#walkNode(childNode, accumulator, walkFunction, parentNode);\n return accumulator;\n }\n\n static #walkNode<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n walkFunction: WalkFunctionMap<TAccumulator>,\n lastNode?: GherkinNode\n ) {\n if (child instanceof Feature && walkFunction.onFeature) {\n const acc = walkFunction.onFeature(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Rule && walkFunction.onRule) {\n const acc = walkFunction.onRule(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Examples) {\n const acc = walkFunction.onExamples?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Example) {\n const acc = walkFunction.onExample?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Scenario) {\n const acc = walkFunction.onScenario?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof ScenarioOutline) {\n const acc = walkFunction.onScenarioOutline?.(\n child,\n accumulator,\n lastNode\n );\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Background) {\n const acc = walkFunction?.onBackground?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Step) {\n const acc = walkFunction.onStep?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n }\n\n static #walkChildren<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n walkFunction: WalkFunctionMap<any>\n ) {\n for (const node of child.children) {\n this.walk(walkFunction, node, accumulator, child);\n }\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport { StepKeyword } from \"@autometa/gherkin\";\nimport { StepType } from \"@autometa/gherkin\";\nimport {\n Scope,\n RuleScope,\n ScenarioScope,\n ScenarioOutlineScope,\n BackgroundScope\n} from \"@autometa/scopes\";\nimport { Empty_Function } from \"@autometa/scopes\";\n\nexport function scope(value: Scope) {\n return {\n findRule: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return child instanceof RuleScope && child.name === name;\n }) as RuleScope | undefined;\n if (!found) {\n const rule = new RuleScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(rule);\n return rule;\n }\n return found;\n },\n findScenario: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return (\n child instanceof ScenarioScope &&\n child.name === name &&\n !(child instanceof ScenarioOutlineScope)\n );\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findBackground: ({ name }: { name?: string }): BackgroundScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof BackgroundScope;\n }) as BackgroundScope | undefined;\n if (found && found.name !== name) {\n throw new AutomationError(\n `Could not find background matching ${name} but found ${found?.name}`\n );\n }\n if (found) {\n return found;\n }\n\n const bgScope = new BackgroundScope(\n name,\n Empty_Function,\n value.hooks,\n value.steps\n );\n value.attach(bgScope);\n return bgScope;\n },\n findScenarioOutline: (name: string): ScenarioOutlineScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof ScenarioOutlineScope && child.name === name;\n }) as ScenarioOutlineScope | undefined;\n if (!found) {\n const scenarioOutline = new ScenarioOutlineScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenarioOutline);\n return scenarioOutline;\n }\n return found;\n },\n findExample(name: string): ScenarioScope {\n const found = value.closedScopes.find((child) => {\n if (!(child instanceof ScenarioScope)) {\n return false;\n }\n return child.name === name;\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findStep: (keywordType: StepType, keyword: StepKeyword, name: string) => {\n return value.steps.find(keywordType, keyword, name);\n }\n };\n}\n","import {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n StepCache\n} from \"@autometa/scopes\";\nimport {\n BackgroundBridge,\n ExampleBridge,\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n StepBridge\n} from \"./bridges\";\nimport { GherkinWalker } from \"./gherkin-walker\";\nimport { scope } from \"./scope-search\";\nimport { Bind } from \"@autometa/bind-decorator\";\nimport {\n Example,\n Feature,\n GherkinNode,\n Scenario,\n scenarioExampleTitle\n} from \"@autometa/gherkin\";\nimport { raise } from \"@autometa/errors\";\nimport { StepKeyword, StepType } from \"@autometa/types\";\nexport class TestBuilder {\n constructor(readonly feature: Feature) {}\n @Bind\n onFeatureExecuted(featureScope: FeatureScope) {\n const bridge = new FeatureBridge();\n GherkinWalker.walk<GherkinCodeBridge>(\n {\n onFeature: (feature, accumulator) => {\n accumulator.data = { gherkin: feature, scope: featureScope };\n return accumulator;\n },\n onRule: (rule, accumulator) => {\n const ruleScope = scope(featureScope).findRule(\n rule.name\n ) as RuleScope;\n const bridge = new RuleBridge();\n bridge.data = { gherkin: rule, scope: ruleScope };\n (accumulator as FeatureBridge).rules.push(bridge);\n return bridge;\n },\n onScenario: (gherkin, accumulator) => {\n const scenarioScope = scope(accumulator.data.scope).findScenario(\n gherkin.name\n );\n const bridge = new ScenarioBridge();\n bridge.data = { gherkin, scope: scenarioScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n // if accumulator is a outline, push to examples\n\n return bridge;\n },\n onScenarioOutline: (gherkin, accumulator) => {\n const outlineScope = scope(\n accumulator.data.scope\n ).findScenarioOutline(gherkin.name);\n const bridge = new ScenarioOutlineBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n return bridge;\n },\n onExamples: (gherkin, accumulator) => {\n const outlineScope = accumulator.data.scope as ScenarioOutlineScope;\n const bridge = new ExamplesBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as ScenarioOutlineBridge).examples.push(bridge);\n return bridge;\n },\n onExample(gherkin, accumulator) {\n if (gherkin.table === undefined) {\n raise(\n `Example ${gherkin.name} has no Example Table data. A Row of data is required.`\n );\n }\n const titleSegments = Object.keys(gherkin.table);\n const values = Object.values(gherkin.table);\n const title = scenarioExampleTitle(\n titleSegments,\n gherkin.name,\n values\n );\n\n const exampleScope = scope(accumulator.data.scope).findExample(title);\n const bridge = new ExampleBridge();\n bridge.data = { gherkin, scope: exampleScope };\n const acc = accumulator as ExamplesBridge;\n acc.scenarios.push(bridge);\n return bridge;\n },\n onBackground(gherkin, accumulator) {\n const backgroundScope = scope(accumulator.data.scope).findBackground({\n name: gherkin.name\n });\n const bridge = new BackgroundBridge();\n bridge.data = { gherkin, scope: backgroundScope };\n const acc = accumulator as FeatureBridge | RuleBridge;\n acc.background = bridge;\n return bridge;\n },\n onStep: (step, accumulator) => {\n const {\n data: { scope: parentScope, gherkin }\n } = accumulator;\n const { keyword, keywordType, text } = step;\n const cache = parentScope.steps;\n const existing = getStep(\n accumulator,\n gherkin,\n cache,\n keywordType,\n keyword,\n text\n );\n const bridge = new StepBridge();\n const acc = accumulator as\n | BackgroundBridge\n | ScenarioBridge\n | RuleBridge\n | FeatureBridge;\n\n if (existing) {\n bridge.data = {\n gherkin: step,\n scope: existing.step,\n args: existing.args\n };\n } else {\n raise(`No step definition matching ${step.keyword} ${step.text}`);\n }\n\n acc.steps.push(bridge);\n return accumulator;\n }\n },\n this.feature,\n bridge\n );\n return bridge;\n }\n}\nfunction getStep(\n accumulator: GherkinCodeBridge,\n gherkin: GherkinNode,\n cache: StepCache,\n keywordType: StepType,\n keyword: StepKeyword,\n text: string\n) {\n try {\n if (accumulator instanceof ExampleBridge) {\n const scenario = gherkin as Example;\n if (scenario.table) {\n return cache.findByExample(keywordType, keyword, text, scenario.table);\n }\n }\n return cache.find(keywordType, keyword, text);\n } catch (e) {\n const cause = e as Error;\n const { title } = gherkin as Scenario;\n raise(\n `'${title}' could not find a step definition`,\n { cause }\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAWO;AAWA,IAAe,oBAAf,MAAiC;AAExC;AACO,IAAM,eAAN,cAA2B,kBAAkB;AAAA,EAElD,YAAYA,QAAoB;AAC9B,UAAM;AACN,UAAM,WAAW,cAAc,2BAAY;AAAA,MAA1B;AAAA;AACf,uBAAU;AAAA;AAAA,IACZ;AACA,SAAK,OAAO;AAAA,MACV,OAAAA;AAAA,MACA,SAAS,IAAI,SAAS;AAAA,IACxB;AAAA,EACF;AACF;AACO,IAAM,gBAAN,cAA4B,kBAAkB;AAAA,EAA9C;AAAA;AAGL,qBAAwD,CAAC;AACzD,iBAAsB,CAAC;AACvB,iBAAsB,CAAC;AAAA;AACzB;AACO,IAAM,mBAAN,cAA+B,kBAAkB;AAAA,EAAjD;AAAA;AAEL,iBAAsB,CAAC;AAAA;AACzB;AAEO,IAAM,aAAN,cAAyB,kBAAkB;AAAA,EAA3C;AAAA;AAGL,qBAAwD,CAAC;AACzD,iBAAsB,CAAC;AAAA;AACzB;AAEO,IAAM,iBAAN,cAA6B,kBAAkB;AAAA,EAA/C;AAAA;AAEL,iBAAsB,CAAC;AACvB,kBAGI,CAAC;AAAA;AAAA,EAEL,IAAI,QAAQ;AACV,WAAO,KAAK,KAAK,MAAM,MAAM,KAAK,KAAK,OAAO;AAAA,EAChD;AAAA,EACA,IAAI,OAAO;AACT,W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;AAAA,MACL;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAnHE;AAAA,EADC;AAAA,GAFU,YAGX;AAoHF,SAAS,QACP,aACA,SACA,OACA,aACA,SACA,MACA;AACA,MAAI;AACF,QAAI,uBAAuB,eAAe;AACxC,YAAM,WAAW;AACjB,UAAI,SAAS,OAAO;AAClB,eAAO,MAAM,cAAc,aAAa,SAAS,MAAM,SAAS,KAAK;AAAA,MACvE;AAAA,IACF;AACA,WAAO,MAAM,KAAK,aAAa,SAAS,IAAI;AAAA,EAC9C,SAAS,GAAG;AACV,UAAM,QAAQ;AACd,UAAM,EAAE,MAAM,IAAI;AAClB;AAAA,MACE,IAAI,KAAK;AAAA,MACT,EAAE,MAAM;AAAA,IACV;AAAA,EACF;AACF;","names":["scope","scope","import_gherkin","import_gherkin","import_errors","import_errors","import_scopes","import_gherkin","import_errors","bridge"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/bridges/bridge.ts","../src/bridges/bridge-search.ts","../src/bridges/bridge-query.ts","../src/gherkin-walker.ts","../src/scope-search.ts","../src/test-builder.ts"],"sourcesContent":["export * from \"./bridges\";\nexport * from \"./test-builder\";\nexport * from \"./scope-search\";\nexport * from \"./gherkin-walker\";\n","import {\n Background,\n DataTable,\n Example,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step,\n} from \"@autometa/gherkin\";\nimport { BackgroundScope, GlobalScope } from \"@autometa/scopes\";\nimport {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n ScenarioScope,\n Scope,\n StepScope,\n} from \"@autometa/scopes\";\n\nexport abstract class GherkinCodeBridge {\n abstract data: { gherkin: GherkinNode; scope: Scope };\n}\nexport class GlobalBridge extends GherkinCodeBridge {\n readonly data: { gherkin: GherkinNode; scope: GlobalScope };\n constructor(scope: GlobalScope) {\n super();\n const nullNode = class extends GherkinNode {\n keyword = \"none\";\n };\n this.data = {\n scope,\n gherkin: new nullNode(),\n };\n }\n}\nexport class FeatureBridge extends GherkinCodeBridge {\n data: { gherkin: Feature; scope: FeatureScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n rules: RuleBridge[] = [];\n steps: StepBridge[] = [];\n}\nexport class BackgroundBridge extends GherkinCodeBridge {\n data: { gherkin: Background; scope: BackgroundScope };\n steps: StepBridge[] = [];\n}\n\nexport class RuleBridge extends GherkinCodeBridge {\n data: { gherkin: Rule; scope: RuleScope };\n background: BackgroundBridge;\n scenarios: (ScenarioBridge | ScenarioOutlineBridge)[] = [];\n steps: StepBridge[] = [];\n}\n\nexport class ScenarioBridge extends GherkinCodeBridge {\n data: { gherkin: Scenario; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ExampleBridge extends GherkinCodeBridge {\n data: { gherkin: Example; scope: ScenarioScope };\n steps: StepBridge[] = [];\n report: {\n passed?: boolean;\n error?: Error;\n } = {};\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\nexport class ScenarioOutlineBridge extends GherkinCodeBridge {\n data: { gherkin: ScenarioOutline; scope: ScenarioOutlineScope };\n examples: ExamplesBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class ExamplesBridge extends GherkinCodeBridge {\n data: { gherkin: Examples; scope: ScenarioOutlineScope };\n scenarios: ScenarioBridge[] = [];\n steps: StepBridge[] = [];\n get title() {\n return this.data.scope.title(this.data.gherkin);\n }\n get tags() {\n return [...this.data.gherkin.tags];\n }\n}\n\nexport class StepBridge extends GherkinCodeBridge {\n data: {\n gherkin: Step;\n scope: StepScope<string, DataTable | undefined>;\n args: unknown[];\n };\n\n get args() {\n return this.data.scope.getArgs(this.data.gherkin.text);\n }\n\n get expressionText() {\n return this.data.scope.expression.source;\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport {\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n RuleBridge,\n} from \"./bridge\";\n\nexport function find(\n bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n if (bridge instanceof FeatureBridge) {\n return findByFeature(bridge, testName);\n }\n if (bridge instanceof RuleBridge) {\n return findByRule(bridge, testName);\n }\n if (bridge instanceof ScenarioOutlineBridge) {\n return findScenarioOutlineOrChild(bridge, testName);\n }\n\n throw new AutomationError(`Could not find test matching ${testName}`);\n}\nfunction findByFeature(\n feature: FeatureBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = feature.data.scope.title(feature.data.gherkin);\n const byScenario = findTestTypes(feature.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleTypes(feature.rules, testName, title);\n if (byRule) {\n return byRule;\n }\n}\nfunction findByRule(\n rule: RuleBridge,\n testName: string\n): GherkinCodeBridge | undefined {\n const title = rule.data.scope.title(rule.data.gherkin);\n const byScenario = findTestTypes(rule.scenarios, testName, title);\n if (byScenario) {\n return byScenario;\n }\n const byRule = findRuleOrChild(rule, testName, title);\n if (byRule) {\n return byRule;\n }\n}\n\nexport function findTestTypes(\n scenarios: (ScenarioBridge | ScenarioOutlineBridge | ExamplesBridge)[],\n testName: string,\n from?: string\n) {\n for (const scenario of scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n const found = findScenarioOutlineOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ExamplesBridge) {\n const found = findExamplesOrChild(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n if (scenario instanceof ScenarioBridge) {\n const found = findScenario(scenario, testName, from);\n if (found) {\n return found;\n }\n }\n }\n}\n\nexport function findRuleTypes(\n rules: RuleBridge[],\n testName: string,\n from?: string\n) {\n for (const rule of rules) {\n const found = findRuleOrChild(rule, testName, from);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findRuleOrChild(\n rule: RuleBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = rule;\n const title = scope.title(gherkin);\n if (testName === title) {\n return rule;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return rule;\n }\n }\n const newFrom = appendPath(from, title);\n return findTestTypes(rule.scenarios, testName, newFrom);\n}\n\nexport function findScenarioOutlineOrChild(\n outline: ScenarioOutlineBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = outline;\n const title = scope.title(gherkin);\n if (testName === title) {\n return outline;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return outline;\n }\n }\n for (const example of outline.examples) {\n const newFrom = appendPath(from, title);\n const found = findExamplesOrChild(example, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nfunction appendPath(from: string | undefined, title: string) {\n return from ? `${from} ${title}` : title;\n}\n\nexport function findExamplesOrChild(\n example: ExamplesBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = example;\n const title = scope.title(gherkin);\n if (testName === title) {\n return example;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return example;\n }\n }\n for (const scenario of example.scenarios) {\n const newFrom = appendPath(from, title);\n const found = findScenario(scenario, testName, newFrom);\n if (found) {\n return found;\n }\n }\n}\n\nexport function findScenario(\n scenario: ScenarioBridge,\n testName: string,\n from?: string\n) {\n const {\n data: { scope, gherkin },\n } = scenario;\n const title = scope.title(gherkin);\n if (testName === title) {\n return scenario;\n }\n if (from) {\n const fullTitle = `${from} ${title}`;\n if (fullTitle === testName) {\n return scenario;\n }\n }\n}\n","import { Background, GherkinNode } from \"@autometa/gherkin\";\nimport {\n FeatureBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n} from \".\";\n\nfunction failed(bridge: FeatureBridge | RuleBridge | ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n if (bridge instanceof ScenarioOutlineBridge) {\n return failedOutline(bridge);\n }\n for (const scenario of bridge.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed && scenario.report.error !== undefined) {\n accumulator.push(scenario);\n }\n }\n if (bridge instanceof FeatureBridge) {\n accumulator.push(...failedRule(bridge));\n }\n return accumulator;\n}\n\nfunction failedOutline(bridge: ScenarioOutlineBridge) {\n const accumulator: ScenarioBridge[] = [];\n\n for (const example of bridge.examples) {\n for (const scenario of example.scenarios) {\n if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction failedRule(bridge: FeatureBridge) {\n const accumulator: ScenarioBridge[] = [];\n for (const rule of bridge.rules) {\n for (const scenario of rule.scenarios) {\n if (scenario instanceof ScenarioOutlineBridge) {\n accumulator.push(...failedOutline(scenario));\n } else if (!scenario.report.passed) {\n accumulator.push(scenario);\n }\n }\n }\n return accumulator;\n}\n\nfunction gherkinToTestNames(\n node: GherkinNode,\n path = \"\",\n accumulator: string[] = []\n) {\n if (!(\"name\" in node) || node instanceof Background) {\n return;\n }\n const title = `${node.keyword}: ${node.name}`;\n const fullPath = path ? `${path} ${title}` : title;\n accumulator.push(fullPath);\n if (!node.children) {\n return;\n }\n for (const child of node.children) {\n if (!(\"name\" in child) || child instanceof Background) {\n continue;\n }\n gherkinToTestNames(child, fullPath, accumulator);\n }\n return accumulator;\n}\n\nexport const Query = {\n find: {\n failed,\n },\n testNames: gherkinToTestNames,\n};\n","import {\n Background,\n Examples,\n Feature,\n GherkinNode,\n Rule,\n Scenario,\n ScenarioOutline,\n Step,\n} from \"@autometa/gherkin\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { Example } from \"@autometa/gherkin\";\n\nexport type WalkFunction<T extends GherkinNode, TAccumulator, TReturn> = (\n node: T,\n accumulator: TAccumulator,\n lastNode?: GherkinNode\n) => TReturn;\n\nexport type WalkFunctionMap<TAccumulator> = {\n onFeature?: WalkFunction<Feature, TAccumulator, TAccumulator>;\n onRule?: WalkFunction<Rule, TAccumulator, TAccumulator>;\n onBackground?: WalkFunction<Background, TAccumulator, TAccumulator>;\n onScenario?: WalkFunction<Scenario, TAccumulator, TAccumulator>;\n onScenarioOutline?: WalkFunction<ScenarioOutline, TAccumulator, TAccumulator>;\n onExamples?: WalkFunction<Examples, TAccumulator, TAccumulator>;\n onExample?: WalkFunction<Example, TAccumulator, TAccumulator>;\n onStep?: WalkFunction<Step, TAccumulator, TAccumulator>;\n};\n\nexport class GherkinWalker {\n static walk<TAccumulator>(\n walkFunction: WalkFunctionMap<TAccumulator>,\n childNode: GherkinNode,\n accumulator: TAccumulator,\n parentNode?: GherkinNode\n ) {\n if (accumulator === undefined) {\n throw new AutomationError(\n `An accumulator must be defined to continue the walker from ${\n childNode.constructor.name\n }${JSON.stringify(childNode)}`\n );\n }\n this.#walkNode(childNode, accumulator, walkFunction, parentNode);\n return accumulator;\n }\n\n static #walkNode<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n walkFunction: WalkFunctionMap<TAccumulator>,\n lastNode?: GherkinNode\n ) {\n if (child instanceof Feature && walkFunction.onFeature) {\n const acc = walkFunction.onFeature(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Rule && walkFunction.onRule) {\n const acc = walkFunction.onRule(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Examples) {\n const acc = walkFunction.onExamples?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Example) {\n const acc = walkFunction.onExample?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Scenario) {\n const acc = walkFunction.onScenario?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof ScenarioOutline) {\n const acc = walkFunction.onScenarioOutline?.(\n child,\n accumulator,\n lastNode\n );\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Background) {\n const acc = walkFunction?.onBackground?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n\n if (child instanceof Step) {\n const acc = walkFunction.onStep?.(child, accumulator, lastNode);\n return this.#walkChildren(child, acc, walkFunction);\n }\n }\n\n static #walkChildren<TAccumulator>(\n child: GherkinNode,\n accumulator: TAccumulator,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n walkFunction: WalkFunctionMap<any>\n ) {\n for (const node of child.children) {\n this.walk(walkFunction, node, accumulator, child);\n }\n }\n}\n","import { AutomationError } from \"@autometa/errors\";\nimport { StepKeyword } from \"@autometa/gherkin\";\nimport { StepType } from \"@autometa/gherkin\";\nimport {\n Scope,\n RuleScope,\n ScenarioScope,\n ScenarioOutlineScope,\n BackgroundScope,\n} from \"@autometa/scopes\";\nimport { Empty_Function } from \"@autometa/scopes\";\n\nexport function scope(value: Scope) {\n return {\n findRule: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return child instanceof RuleScope && child.name === name;\n }) as RuleScope | undefined;\n if (!found) {\n const rule = new RuleScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(rule);\n return rule;\n }\n return found;\n },\n findScenario: (name: string) => {\n const found = value.closedScopes.find((child) => {\n return (\n child instanceof ScenarioScope &&\n child.name === name &&\n !(child instanceof ScenarioOutlineScope)\n );\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findBackground: ({ name }: { name?: string }): BackgroundScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof BackgroundScope;\n }) as BackgroundScope | undefined;\n if (found && found.name !== name) {\n throw new AutomationError(\n `Could not find background matching ${name} but found ${found?.name}`\n );\n }\n if (found) {\n return found;\n }\n\n const bgScope = new BackgroundScope(\n name,\n Empty_Function,\n value.hooks,\n value.steps\n );\n value.attach(bgScope);\n return bgScope;\n },\n findScenarioOutline: (name: string): ScenarioOutlineScope => {\n const found = value.closedScopes.find((child) => {\n return child instanceof ScenarioOutlineScope && child.name === name;\n }) as ScenarioOutlineScope | undefined;\n if (!found) {\n const scenarioOutline = new ScenarioOutlineScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenarioOutline);\n return scenarioOutline;\n }\n return found;\n },\n findExample(name: string): ScenarioScope {\n const found = value.closedScopes.find((child) => {\n if (!(child instanceof ScenarioScope)) {\n return false;\n }\n return child.name === name;\n }) as ScenarioScope;\n if (!found) {\n const scenario = new ScenarioScope(\n name,\n Empty_Function,\n undefined,\n value.hooks,\n value.steps\n );\n value.attach(scenario);\n return scenario;\n }\n return found;\n },\n findStep: (keywordType: StepType, keyword: StepKeyword, name: string) => {\n return value.steps.find(keywordType, keyword, name);\n },\n };\n}\n","import {\n FeatureScope,\n RuleScope,\n ScenarioOutlineScope,\n StepCache,\n} from \"@autometa/scopes\";\nimport {\n BackgroundBridge,\n ExampleBridge,\n ExamplesBridge,\n FeatureBridge,\n GherkinCodeBridge,\n RuleBridge,\n ScenarioBridge,\n ScenarioOutlineBridge,\n StepBridge,\n} from \"./bridges\";\nimport { GherkinWalker } from \"./gherkin-walker\";\nimport { scope } from \"./scope-search\";\nimport { Bind } from \"@autometa/bind-decorator\";\nimport {\n Example,\n Feature,\n GherkinNode,\n Scenario,\n scenarioExampleTitle,\n} from \"@autometa/gherkin\";\nimport { raise } from \"@autometa/errors\";\nimport { StepKeyword, StepType } from \"@autometa/types\";\nexport class TestBuilder {\n constructor(readonly feature: Feature) {}\n @Bind\n onFeatureExecuted(featureScope: FeatureScope) {\n const bridge = new FeatureBridge();\n GherkinWalker.walk<GherkinCodeBridge>(\n {\n onFeature: (feature, accumulator) => {\n accumulator.data = { gherkin: feature, scope: featureScope };\n return accumulator;\n },\n onRule: (rule, accumulator) => {\n const ruleScope = scope(featureScope).findRule(\n rule.name\n ) as RuleScope;\n const bridge = new RuleBridge();\n bridge.data = { gherkin: rule, scope: ruleScope };\n (accumulator as FeatureBridge).rules.push(bridge);\n return bridge;\n },\n onScenario: (gherkin, accumulator) => {\n const scenarioScope = scope(accumulator.data.scope).findScenario(\n gherkin.name\n );\n const bridge = new ScenarioBridge();\n bridge.data = { gherkin, scope: scenarioScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n // if accumulator is a outline, push to examples\n\n return bridge;\n },\n onScenarioOutline: (gherkin, accumulator) => {\n const outlineScope = scope(\n accumulator.data.scope\n ).findScenarioOutline(gherkin.name);\n const bridge = new ScenarioOutlineBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as FeatureBridge | RuleBridge).scenarios.push(bridge);\n return bridge;\n },\n onExamples: (gherkin, accumulator) => {\n const outlineScope = accumulator.data.scope as ScenarioOutlineScope;\n const bridge = new ExamplesBridge();\n bridge.data = { gherkin, scope: outlineScope };\n (accumulator as ScenarioOutlineBridge).examples.push(bridge);\n return bridge;\n },\n onExample(gherkin, accumulator) {\n if (gherkin.table === undefined) {\n raise(\n `Example ${gherkin.name} has no Example Table data. A Row of data is required.`\n );\n }\n const titleSegments = Object.keys(gherkin.table);\n const values = Object.values(gherkin.table);\n const title = scenarioExampleTitle(\n titleSegments,\n gherkin.name,\n values\n );\n\n const exampleScope = scope(accumulator.data.scope).findExample(title);\n const bridge = new ExampleBridge();\n bridge.data = { gherkin, scope: exampleScope };\n const acc = accumulator as ExamplesBridge;\n acc.scenarios.push(bridge);\n return bridge;\n },\n onBackground(gherkin, accumulator) {\n const backgroundScope = scope(accumulator.data.scope).findBackground({\n name: gherkin.name,\n });\n const bridge = new BackgroundBridge();\n bridge.data = { gherkin, scope: backgroundScope };\n const acc = accumulator as FeatureBridge | RuleBridge;\n acc.background = bridge;\n return bridge;\n },\n onStep: (step, accumulator) => {\n const {\n data: { scope: parentScope, gherkin },\n } = accumulator;\n const { keyword, keywordType, text } = step;\n const cache = parentScope.steps;\n const existing = getStep(\n accumulator,\n gherkin,\n cache,\n keywordType,\n keyword,\n text\n );\n const bridge = new StepBridge();\n const acc = accumulator as\n | BackgroundBridge\n | ScenarioBridge\n | RuleBridge\n | FeatureBridge;\n\n if (existing) {\n bridge.data = {\n gherkin: step,\n scope: existing.step,\n args: existing.args,\n };\n } else {\n raise(`No step definition matching ${step.keyword} ${step.text}`);\n }\n\n acc.steps.push(bridge);\n return accumulator;\n },\n },\n this.feature,\n bridge\n );\n return bridge;\n }\n}\nfunction getStep(\n accumulator: GherkinCodeBridge,\n gherkin: GherkinNode,\n cache: StepCache,\n keywordType: StepType,\n keyword: StepKeyword,\n text: string\n) {\n try {\n if (accumulator instanceof ExampleBridge) {\n const scenario = gherkin as Example;\n if (scenario.table) {\n return cache.findByExample(keywordType, keyword, text, scenario.table);\n }\n }\n return cache.find(keywordType, keyword, text);\n } catch (e) {\n const cause = e as Error;\n const { title } = gherkin as Scenario;\n raise(`'${title}' could not find a step definition`, { cause });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAWO;AAWA,IAAe,oBAAf,MAAiC;AAExC;AACO,IAAM,eAAN,cAA2B,kBAAkB;AAAA,EAElD,YAAYA,QAAoB;AAC9B,UAAM;AACN,UAAM,WAAW,cAAc,2BAAY;AAAA,MAA1B;AAAA;AACf,uBAAU;AAAA;AAAA,IACZ;AACA,SAAK,OAAO;AAAA,MACV,OAAAA;AAAA,MAC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B;AAC7B,gBAAM;AAAA,YACJ,MAAM,EAAE,OAAO,aAAa,QAAQ;AAAA,UACtC,IAAI;AACJ,gBAAM,EAAE,SAAS,aAAa,KAAK,IAAI;AACvC,gBAAM,QAAQ,YAAY;AAC1B,gBAAM,WAAW;AAAA,YACf;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AACA,gBAAMA,UAAS,IAAI,WAAW;AAC9B,gBAAM,MAAM;AAMZ,cAAI,UAAU;AACZ,YAAAA,QAAO,OAAO;AAAA,cACZ,SAAS;AAAA,cACT,OAAO,SAAS;AAAA,cAChB,MAAM,SAAS;AAAA,YACjB;AAAA,UACF,OAAO;AACL,sCAAM,+BAA+B,KAAK,OAAO,IAAI,KAAK,IAAI,EAAE;AAAA,UAClE;AAEA,cAAI,MAAM,KAAKA,OAAM;AACrB,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,KAAK;AAAA,MACL;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAnHE;AAAA,EADC;AAAA,GAFU,YAGX;AAoHF,SAAS,QACP,aACA,SACA,OACA,aACA,SACA,MACA;AACA,MAAI;AACF,QAAI,uBAAuB,eAAe;AACxC,YAAM,WAAW;AACjB,UAAI,SAAS,OAAO;AAClB,eAAO,MAAM,cAAc,aAAa,SAAS,MAAM,SAAS,KAAK;AAAA,MACvE;AAAA,IACF;AACA,WAAO,MAAM,KAAK,aAAa,SAAS,IAAI;AAAA,EAC9C,SAAS,GAAG;AACV,UAAM,QAAQ;AACd,UAAM,EAAE,MAAM,IAAI;AAClB,8BAAM,IAAI,KAAK,sCAAsC,EAAE,MAAM,CAAC;AAAA,EAChE;AACF;","names":["scope","scope","import_gherkin","import_gherkin","import_errors","import_errors","import_scopes","import_gherkin","import_errors","bridge"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autometa/test-builder",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "internal library for autometa",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,30 +18,31 @@
|
|
|
18
18
|
"@types/uuid": "^9.0.5",
|
|
19
19
|
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
20
20
|
"@typescript-eslint/parser": "^5.54.1",
|
|
21
|
-
"@vitest/coverage-istanbul": "^
|
|
21
|
+
"@vitest/coverage-istanbul": "^1.4.0",
|
|
22
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
22
23
|
"eslint": "^8.37.0",
|
|
23
|
-
"eslint-config-custom": "0.6.0",
|
|
24
24
|
"eslint-config-prettier": "^8.3.0",
|
|
25
25
|
"istanbul": "^0.4.5",
|
|
26
26
|
"rimraf": "^4.1.2",
|
|
27
|
-
"tsconfig": " *",
|
|
28
27
|
"tsup": "^7.2.0",
|
|
29
28
|
"typescript": "^4.9.5",
|
|
30
|
-
"vitest": "
|
|
29
|
+
"vitest": "1.4.0",
|
|
30
|
+
"tsconfig": "0.7.0",
|
|
31
|
+
"eslint-config-custom": "0.6.0"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
34
|
+
"@cucumber/cucumber-expressions": "^16.1.2",
|
|
35
|
+
"zod": "^3.21.4",
|
|
35
36
|
"@autometa/bind-decorator": "^0.5.1",
|
|
37
|
+
"@autometa/asserters": "^0.1.8",
|
|
36
38
|
"@autometa/dto-builder": "^0.13.9",
|
|
37
39
|
"@autometa/errors": "^0.2.2",
|
|
38
|
-
"@autometa/
|
|
39
|
-
"@autometa/gherkin": "^0.6.
|
|
40
|
-
"@autometa/
|
|
41
|
-
"@autometa/
|
|
40
|
+
"@autometa/app": "^0.3.4",
|
|
41
|
+
"@autometa/gherkin": "^0.6.10",
|
|
42
|
+
"@autometa/scopes": "^0.5.12",
|
|
43
|
+
"@autometa/events": "^0.2.22",
|
|
42
44
|
"@autometa/types": "^0.4.1",
|
|
43
|
-
"@
|
|
44
|
-
"zod": "^3.21.4"
|
|
45
|
+
"@autometa/phrases": "^0.1.12"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"test": "vitest run --passWithNoTests",
|
|
@@ -52,6 +53,5 @@
|
|
|
52
53
|
"clean": "rimraf dist",
|
|
53
54
|
"build": "tsup",
|
|
54
55
|
"build:watch": "tsup --watch"
|
|
55
|
-
}
|
|
56
|
-
"readme": "# Introduction\n\nThere's nothing here yet"
|
|
56
|
+
}
|
|
57
57
|
}
|
package/tsup.config.ts
CHANGED
|
@@ -4,7 +4,7 @@ export default defineConfig({
|
|
|
4
4
|
clean: true, // clean up the dist folder
|
|
5
5
|
format: ["cjs", "esm"], // generate cjs and esm files
|
|
6
6
|
dts: true,
|
|
7
|
-
sourcemap:true, // generate sourcemaps
|
|
7
|
+
sourcemap: true, // generate sourcemaps
|
|
8
8
|
skipNodeModulesBundle: true,
|
|
9
9
|
entryPoints: ["src/index.ts"],
|
|
10
10
|
target: "es2020",
|