Skip to content
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

honour order of paths in configuration #2345

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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