diff --git a/src/gen/importTestFrom.ts b/src/gen/importTestFrom.ts index 62e736f7..f72af324 100644 --- a/src/gen/importTestFrom.ts +++ b/src/gen/importTestFrom.ts @@ -33,8 +33,7 @@ export class ImportTestFromGuesser { } private fillCustomTestsFromRegularSteps() { - this.usedStepDefinitions.forEach((stepDefinition) => { - const { customTest } = stepDefinition.options; + this.usedStepDefinitions.forEach(({ customTest }) => { if (customTest) this.customTestsSet.add(customTest); }); } diff --git a/src/gen/testFile.ts b/src/gen/testFile.ts index d486648b..c7c59d5a 100644 --- a/src/gen/testFile.ts +++ b/src/gen/testFile.ts @@ -300,7 +300,7 @@ export class TestFile { index, keywordEng, pickleStep, - pomNode: stepDefinition.options.pomNode, + pomNode: stepDefinition.pomNode, }); // for decorator steps, line and fixtureNames are filled later in second pass @@ -424,8 +424,7 @@ export class TestFile { private getWorldFixtureName() { const worldFixtureNames = new Set(); - this.usedStepDefinitions.forEach((stepDefinition) => { - const { worldFixture } = stepDefinition.options; + this.usedStepDefinitions.forEach(({ worldFixture }) => { if (worldFixture) worldFixtureNames.add(worldFixture); }); diff --git a/src/steps/stepDefinition.ts b/src/steps/stepDefinition.ts index 8f2a9dc6..e30d613b 100644 --- a/src/steps/stepDefinition.ts +++ b/src/steps/stepDefinition.ts @@ -24,7 +24,7 @@ export type StepDefinitionOptions = { export class StepDefinition { #expression?: Expression; - constructor(public options: StepDefinitionOptions) {} + constructor(private options: StepDefinitionOptions) {} get keyword() { return this.options.keyword; @@ -46,6 +46,18 @@ export class StepDefinition { return this.options.location.line; } + get customTest() { + return this.options.customTest; + } + + get pomNode() { + return this.options.pomNode; + } + + get worldFixture() { + return this.options.worldFixture; + } + get expression() { // create expression lazily b/c we need all parameter types to be loaded if (!this.#expression) { @@ -65,14 +77,14 @@ export class StepDefinition { /** * Decorator steps have pom node. */ - isDecorator(): this is this & { options: StepDefinitionOptions & { pomNode: PomNode } } { + isDecorator(): this is this & { pomNode: PomNode } { return Boolean(this.options.pomNode); } /** * New cucumber-style steps have worldFixture in step config. */ - isCucumberStyle(): this is this & { options: StepDefinitionOptions & { worldFixture: string } } { + isCucumberStyle(): this is this & { worldFixture: string } { return Boolean(this.options.worldFixture); } }