-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
Cucumber ignores line filter when the feature file is described using an absolute path:
So this works:
cucumber-js ./features/example.feature:3
But this doesn't work and all scenarios from example.feature are executed, not just the one on line 3:
cucumber-js /Users/jan/cucumber-demo/features/example.feature:3
Original issue reported at protractor-cucumber-framework/protractor-cucumber-framework#238
Possibly related:
To Reproduce
Please have a look at the repository where I'm demonstrating the issue.
I think the issue comes down to this:
- given
featurePathsare absolute, so[ '/Users/jan/cucumber-demo/features/example.feature:3' ] - they're provided to
PickleLineFilter, which createsfeatureUriToLinesMappingas follows:
{
"/Users/jan/cucumber-demo/features/example.feature": [
3
]
}
- next, when
PickleFilterchecks withPickleLineFilterif a givenpicklematchesAnyLine, it provides it with a relativepickle.uri - this then means that the following check can't work:
const uri = path.normalize(pickle.uri) // relative path
const linesToMatch = this.featureUriToLinesMapping[uri] // a map of absolute paths -> line numbers- and all scenarios from a given feature file are included
Proposed solution
I think that since PickleLineFilter has access to cwd (which it seems to be ignoring at the moment) it might be useful to ensure that both the featureUriToLinesMapping and matchesAnyLine rely on absolute paths.
Expected behaviour
Line number filters should work for both relative and absolute paths.
Desktop (please complete the following information):
- OS: MacOS
- Version: Checked on Cucumber 5, 6 and 7