From 7648744e3634628623c49688416fd1b01dd6307b Mon Sep 17 00:00:00 2001 From: Luan Taraschi <130802253+luantaraschi@users.noreply.github.com> Date: Thu, 15 Oct 2026 07:49:59 -0300 Subject: [PATCH] fix(run-multiple): keep test patterns globbable when --config is passed With --config, run-multiple resolved config.tests and gherkin.features with path.resolve. On Windows this produced backslash paths, which glob treats as escapes, so no feature files were found. An array of patterns made path.resolve throw a TypeError on every platform. Resolve each pattern separately and use forward slashes. Fixes #5358 --- lib/command/run-multiple.js | 9 +++++++-- test/unit/command/run_multiple_test.js | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/unit/command/run_multiple_test.js 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)) + }) + }) +})