-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI: Targetting the same file multiple times seems to duplicate the results #1706
Comments
Thanks for the report @nicojs. Just to clarify, it seems like you're running into this when using a Scenario Outline with an Examples table. I assume it doesn't occur with regular Scenarios? |
It also occurs with regular scenarios. I've dug a little deeper and found out the issue: cucumber-js/src/cli/configuration_builder.ts Lines 144 to 147 in ea4d860
Feature files are expanded but not deduplicated. This fixes it: async expandFeaturePaths(featurePaths: string[]): Promise<string[]> {
featurePaths = featurePaths.map((p) => p.replace(/(:\d+)*$/g, '')) // Strip line numbers
+ featurePaths = [...new Set(featurePaths)]; // Deduplicate the feature files
return this.expandPaths(featurePaths, '.feature')
} You want me to create a PR? Does this warrant a feature file? Or unit testing? |
The fix seems straight forward enough to not deem itself worthy for a feature file IMHO 🤷♂️ See PR #1708 |
Ah thanks, good find. FWIW we do have a notation that supports targeting multiple lines in the same file, check out this scenario https://github.com/cucumber/cucumber-js/blob/main/features/target_specific_scenarios_by_line.feature#L40. If you're willing to do a PR to add the deduplication though that would be great. I think another scenario in the aforementioned file (as I think that's the most likely circumstance to hit this) plus relevant unit testing would be right in terms of coverage. |
Ah cool! I was looking for exactly that 😆I will use that then
PR is ready. I will add the scenario too, no problem. |
Ok, added it. I've transformed the scenario to a scenario outline with 2 examples. I've also manually "mutation tested" it. |
Describe the bug
In order to save time, I'm trying to use cucumber-js to target individual features and examples (a lot of them). I'm using these arguments:
(to target 2 examples)
However, instead of saving time, it just takes more time. It seems that both examples are now executed twice.
To Reproduce
npx cucumber-js features/simple_math.feature:19
, see:npx cucumber-js features/simple_math.feature:20
, see:npx cucumber-js features/simple_math.feature:19 features/simple_math.feature:20
, see:Expected behavior
Desktop (please complete the following information):
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: