Skip to content

Commit

Permalink
Correct an issue with string stepDefinitions
Browse files Browse the repository at this point in the history
This fixes #781.
  • Loading branch information
badeball committed Jul 31, 2022
1 parent d7f0de6 commit f7de16e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Other changes:

- Added native support for HTML reports using `@cucumber/html-formatter`, fixes [#780](https://github.com/badeball/cypress-cucumber-preprocessor/issues/780).

- Correct an issue with non-array `stepDefinitions`, fixes [#781](https://github.com/badeball/cypress-cucumber-preprocessor/issues/781).

## v11.5.1

- Expose member `getStepDefinitionPatterns`.
Expand Down
32 changes: 32 additions & 0 deletions features/issues/781.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://github.com/badeball/cypress-cucumber-preprocessor/issues/781

Feature: non-array step definitions, not matching
Scenario: non-array step definitions, not matching
Given additional preprocessor configuration
"""
{
"stepDefinitions": "foo/bar"
}
"""
And a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given an undefined step
"""
When I run cypress
Then it fails
And the output should contain
"""
Step implementation missing for "an undefined step".
We tried searching for files containing step definitions using the following search pattern templates:
- foo/bar
These templates resolved to the following search patterns:
- foo/bar
These patterns matched **no files** containing step definitions. This almost certainly means that you have misconfigured `stepDefinitions`.
"""
4 changes: 2 additions & 2 deletions lib/create-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface CompositionContext {
stack: messages.Envelope[];
};
stepDefinitionHints: {
stepDefinitions: string[];
stepDefinitions: string | string[];
stepDefinitionPatterns: string[];
stepDefinitionPaths: string[];
};
Expand Down Expand Up @@ -894,7 +894,7 @@ function createMissingStepDefinitionMessage(
.replaceAll("<text>", text)
.replaceAll(
"<step-definitions>",
prettyPrintList(stepDefinitionHints.stepDefinitions)
prettyPrintList([stepDefinitionHints.stepDefinitions].flat())
)
.replaceAll(
"<step-definition-patterns>",
Expand Down

0 comments on commit f7de16e

Please sign in to comment.