diff --git a/lib/command/run-multiple.js b/lib/command/run-multiple.js index 19bf7a622..84fa5a5ee 100644 --- a/lib/command/run-multiple.js +++ b/lib/command/run-multiple.js @@ -75,10 +75,10 @@ export default async function (selectedRuns, options) { if (options.config) { // update paths to config path if (config.tests) { - config.tests = path.resolve(testRoot, config.tests) + config.tests = resolvePatterns(testRoot, config.tests) } if (config.gherkin && config.gherkin.features) { - config.gherkin.features = path.resolve(testRoot, config.gherkin.features) + config.gherkin.features = resolvePatterns(testRoot, config.gherkin.features) } } @@ -117,6 +117,11 @@ export default async function (selectedRuns, options) { }) } +export function resolvePatterns(testRoot, patterns) { + const resolve = pattern => path.resolve(testRoot, pattern).split(path.sep).join(path.posix.sep) + return Array.isArray(patterns) ? patterns.map(resolve) : resolve(patterns) +} + function executeRun(runName, runConfig) { // clone config let overriddenConfig = { ...config } diff --git a/test/unit/command/run_multiple_test.js b/test/unit/command/run_multiple_test.js new file mode 100644 index 000000000..fc53c471a --- /dev/null +++ b/test/unit/command/run_multiple_test.js @@ -0,0 +1,24 @@ +import { expect } from 'chai' +import path from 'path' +import { fileURLToPath } from 'url' +import { globSync } from 'glob' +import { resolvePatterns } from '../../../lib/command/run-multiple.js' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) +const testRoot = path.join(__dirname, '../../data/sandbox') + +describe('run-multiple command', () => { + describe('resolvePatterns', () => { + it('should resolve a pattern that glob can match', () => { + const pattern = resolvePatterns(testRoot, './features/*.feature') + expect(path.isAbsolute(pattern)).to.be.true + expect(globSync(pattern)).to.have.lengthOf(globSync('./features/*.feature', { cwd: testRoot }).length).and.not.be.empty + }) + + it('should resolve each pattern of an array', () => { + const patterns = resolvePatterns(testRoot, ['./features/checkout.feature', './features/async.feature']) + expect(patterns).to.have.lengthOf(2) + patterns.forEach(pattern => expect(globSync(pattern)).to.have.lengthOf(1)) + }) + }) +})