Skip to content

Commit ba0be00

Browse files
miraoclaude
andauthored
fix(workers): create output directory of each run in run-workers (#5807) (#5809)
With a `multiple` config, run-workers set each worker's output to <output>/<run>_<browser>N but never created it, so tests writing into output_dir failed with ENOENT unless a plugin created the folder first. Also remove the folder left behind by the custom output folder name test. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7b9c333 commit ba0be00

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎lib/workers.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ const createWorkerObjects = (testGroups, config, testRoot, options, selectedRuns
183183
workerObj.setTestRoot(testRoot)
184184
workerObj.addOptions(options)
185185
workerObj.runOutputDir = path.resolve(testRoot, finalConfig.output)
186+
mkdirp.sync(workerObj.runOutputDir)
186187
testWorkerArray.push(workerObj)
187188
})
188189
workers.push(...testWorkerArray)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const config = {
2+
tests: './workers-multiple-browsers/*.js',
3+
timeout: 10000,
4+
output: './output/workers-multiple-output',
5+
helpers: {
6+
FakeDriver: {
7+
require: '../fake_driver',
8+
browser: 'dummy',
9+
},
10+
},
11+
include: {},
12+
mocha: {},
13+
multiple: {
14+
dev: {
15+
browsers: ['chromium', 'webkit'],
16+
},
17+
},
18+
name: 'sandbox',
19+
}

‎test/runner/run_workers_test.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ describe('CodeceptJS Workers Runner', function () {
225225
expect(stdout).toContain(customName)
226226
if (fs.existsSync(outputDir)) {
227227
createdOutput = true
228+
fs.rmSync(outputDir, { recursive: true, force: true })
228229
}
229230
expect(createdOutput).toEqual(true)
230231
expect(err).toEqual(null)
@@ -574,6 +575,21 @@ describe('CodeceptJS Workers Runner', function () {
574575
})
575576
})
576577

578+
it('should create output directory of each run in multi-run', function (done) {
579+
if (!semver.satisfies(process.version, '>=11.7.0')) this.skip('not for node version')
580+
const outputDir = path.join(codecept_dir, 'output', 'workers-multiple-output')
581+
fs.rmSync(outputDir, { recursive: true, force: true })
582+
583+
exec(`${codecept_run_glob('codecept.workers-multiple-output.conf.js')} 2 dev`, (err, stdout) => {
584+
expect(stdout).toMatch(/OK\s+\|\s+8 passed/)
585+
expect(err).toEqual(null)
586+
for (const run of ['dev_chromium1', 'dev_webkit1']) {
587+
expect(fs.existsSync(path.join(outputDir, run))).toEqual(true)
588+
}
589+
done()
590+
})
591+
})
592+
577593
it('should write one JUnit report per browser with all suites of that browser in multi-run --by suite', function (done) {
578594
if (!semver.satisfies(process.version, '>=11.7.0')) this.skip('not for node version')
579595
const outputDir = path.join(codecept_dir, 'output', 'junit-multiple')

0 commit comments

Comments
 (0)