Skip to content

Commit f7de16e

Browse files
committed
Correct an issue with string stepDefinitions
This fixes #781.
1 parent d7f0de6 commit f7de16e

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Other changes:
3636

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

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

4143
- Expose member `getStepDefinitionPatterns`.

features/issues/781.feature

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# https://github.com/badeball/cypress-cucumber-preprocessor/issues/781
2+
3+
Feature: non-array step definitions, not matching
4+
Scenario: non-array step definitions, not matching
5+
Given additional preprocessor configuration
6+
"""
7+
{
8+
"stepDefinitions": "foo/bar"
9+
}
10+
"""
11+
And a file named "cypress/e2e/a.feature" with:
12+
"""
13+
Feature: a feature
14+
Scenario: a scenario
15+
Given an undefined step
16+
"""
17+
When I run cypress
18+
Then it fails
19+
And the output should contain
20+
"""
21+
Step implementation missing for "an undefined step".
22+
23+
We tried searching for files containing step definitions using the following search pattern templates:
24+
25+
- foo/bar
26+
27+
These templates resolved to the following search patterns:
28+
29+
- foo/bar
30+
31+
These patterns matched **no files** containing step definitions. This almost certainly means that you have misconfigured `stepDefinitions`.
32+
"""

lib/create-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface CompositionContext {
5353
stack: messages.Envelope[];
5454
};
5555
stepDefinitionHints: {
56-
stepDefinitions: string[];
56+
stepDefinitions: string | string[];
5757
stepDefinitionPatterns: string[];
5858
stepDefinitionPaths: string[];
5959
};
@@ -894,7 +894,7 @@ function createMissingStepDefinitionMessage(
894894
.replaceAll("<text>", text)
895895
.replaceAll(
896896
"<step-definitions>",
897-
prettyPrintList(stepDefinitionHints.stepDefinitions)
897+
prettyPrintList([stepDefinitionHints.stepDefinitions].flat())
898898
)
899899
.replaceAll(
900900
"<step-definition-patterns>",

0 commit comments

Comments
 (0)