Skip to content

Commit

Permalink
honour order of paths in configuration (#2345)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss authored Oct 20, 2023
1 parent 52fa813 commit f98d567
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.

## [Unreleased]
### Fixed
- Honour order of paths in configuration ([#2345](https://github.com/cucumber/cucumber-js/pull/2345))

## [10.0.0] - 2023-10-09
### Added
Expand Down
3 changes: 1 addition & 2 deletions src/api/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ async function expandPaths(
return [match]
})
)
return expanded.flat()
return expanded.flat().sort()
})
)
const normalized = expandedPaths.flat().map((x) => path.normalize(x))
normalized.sort()
return [...new Set(normalized)]
}

Expand Down
52 changes: 52 additions & 0 deletions src/api/paths_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,58 @@ describe('resolvePaths', () => {
})
})

describe('multiple paths ordering', async () => {
it('should honour the provided order of multiple files', async () => {
// Arrange
const cwd = await buildTestWorkingDirectory()
const featurePathA = path.join(cwd, 'features', 'a.feature')
const featurePathB = path.join(cwd, 'features', 'b.feature')
await fsExtra.outputFile(featurePathA, '')
await fsExtra.outputFile(featurePathB, '')
// Act
const { featurePaths } = await resolvePaths(
new FakeLogger(),
cwd,
{
paths: ['features/b.feature', 'features/a.feature'],
},
{
requireModules: [],
requirePaths: [],
importPaths: [],
}
)

// Assert
expect(featurePaths).to.eql([featurePathB, featurePathA])
})

it('should honour the provided order of multiple directories', async () => {
// Arrange
const cwd = await buildTestWorkingDirectory()
const featurePathA = path.join(cwd, 'features-a', 'something.feature')
const featurePathB = path.join(cwd, 'features-b', 'something.feature')
await fsExtra.outputFile(featurePathA, '')
await fsExtra.outputFile(featurePathB, '')
// Act
const { featurePaths } = await resolvePaths(
new FakeLogger(),
cwd,
{
paths: ['features-b', 'features-a'],
},
{
requireModules: [],
requirePaths: [],
importPaths: [],
}
)

// Assert
expect(featurePaths).to.eql([featurePathB, featurePathA])
})
})

describe('path to an empty rerun file', () => {
it('returns empty featurePaths and support code paths', async function () {
// Arrange
Expand Down

0 comments on commit f98d567

Please sign in to comment.