diff --git a/src/pickle_filter.js b/src/pickle_filter.js index 447a72cdf..2cfa1550d 100644 --- a/src/pickle_filter.js +++ b/src/pickle_filter.js @@ -1,4 +1,5 @@ import _ from 'lodash' +import path from 'path' import { TagExpressionParser } from 'cucumber-tag-expressions' const FEATURE_LINENUM_REGEXP = /^(.*?)((?::[\d]+)+)?$/ @@ -20,7 +21,7 @@ export default class PickleFilter { featurePaths.forEach(featurePath => { const match = FEATURE_LINENUM_REGEXP.exec(featurePath) if (match) { - const uri = match[1] + const uri = path.resolve(match[1]) const linesExpression = match[2] if (linesExpression) { if (!mapping[uri]) { @@ -47,7 +48,7 @@ export default class PickleFilter { } matchesAnyLine({ pickle, uri }) { - const lines = this.featureUriToLinesMapping[uri] + const lines = this.featureUriToLinesMapping[path.resolve(uri)] if (lines) { return _.size(_.intersection(lines, _.map(pickle.locations, 'line'))) > 0 } else { diff --git a/src/pickle_filter_spec.js b/src/pickle_filter_spec.js index 1e616e028..fbc313ccf 100644 --- a/src/pickle_filter_spec.js +++ b/src/pickle_filter_spec.js @@ -71,6 +71,32 @@ describe('PickleFilter', function() { }) }) }) + + describe('scenario line using current directory path representation', function() { + beforeEach(function() { + this.input.uri = './features/b.feature' + }) + + describe('scenario line matches', function() { + beforeEach(function() { + this.input.pickle.locations = [{ line: 1 }] + }) + + it('returns true', function() { + expect(this.pickleFilter.matches(this.input)).to.be.true + }) + }) + + describe('scenario line does not match', function() { + beforeEach(function() { + this.input.pickle.locations = [{ line: 3 }] + }) + + it('returns false', function() { + expect(this.pickleFilter.matches(this.input)).to.be.false + }) + }) + }) }) describe('name filters', function() { @@ -321,7 +347,6 @@ describe('PickleFilter', function() { tagExpressions: ['tagA'] }) this.input.pickle.locations = [{ line: 1 }] - this.input.uri = this.scenarioPath }) it('returns false', function() { @@ -337,7 +362,6 @@ describe('PickleFilter', function() { tagExpression: '@tagA' }) this.input.pickle.locations = [{ line: 1 }] - this.input.uri = this.scenarioPath }) it('returns false', function() {