Skip to content

Commit 2c7f0f6

Browse files
committed
fix pickle filter for windows
1 parent fe64bf1 commit 2c7f0f6

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/pickle_filter.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import _ from 'lodash'
2+
import path from 'path'
23
import parse from '@cucumber/tag-expressions'
34
import { getGherkinScenarioLocationMap } from './formatter/helpers/gherkin_document_parser'
45
import { doesHaveValue, doesNotHaveValue } from './value_checker'
@@ -56,23 +57,20 @@ export class PickleLineFilter {
5657

5758
constructor(cwd: string, featurePaths: string[] = []) {
5859
this.featureUriToLinesMapping = this.getFeatureUriToLinesMapping({
59-
cwd,
6060
featurePaths,
6161
})
6262
}
6363

6464
getFeatureUriToLinesMapping({
65-
cwd,
6665
featurePaths,
6766
}: {
68-
cwd: string
6967
featurePaths: string[]
7068
}): Record<string, number[]> {
7169
const mapping: Record<string, number[]> = {}
7270
featurePaths.forEach((featurePath) => {
7371
const match = FEATURE_LINENUM_REGEXP.exec(featurePath)
7472
if (doesHaveValue(match)) {
75-
const uri = match[1]
73+
const uri = path.normalize(match[1])
7674
const linesExpression = match[2]
7775
if (doesHaveValue(linesExpression)) {
7876
if (doesNotHaveValue(mapping[uri])) {
@@ -91,7 +89,8 @@ export class PickleLineFilter {
9189
}
9290

9391
matchesAnyLine({ gherkinDocument, pickle }: IMatchesAnyLineRequest): boolean {
94-
const linesToMatch = this.featureUriToLinesMapping[pickle.uri]
92+
const uri = path.normalize(pickle.uri)
93+
const linesToMatch = this.featureUriToLinesMapping[uri]
9594
if (doesHaveValue(linesToMatch)) {
9695
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
9796
gherkinDocument

src/pickle_filter_spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { beforeEach, describe, it } from 'mocha'
22
import { expect } from 'chai'
33
import PickleFilter from './pickle_filter'
4-
import path from 'path'
54
import { parse } from '../test/gherkin_helpers'
65

76
describe('PickleFilter', () => {
@@ -84,7 +83,7 @@ describe('PickleFilter', () => {
8483
expect(result).to.eql(true)
8584
})
8685

87-
it('returns true if pickle line does not match', async function () {
86+
it('returns false if pickle line does not match', async function () {
8887
// Arrange
8988
const {
9089
pickles: [pickle],

0 commit comments

Comments
 (0)