Skip to content

Commit a15acc3

Browse files
DavertMikclaude
andcommitted
fix: address PR feedback on programmatic API and workers
- runner.js: escape regex metacharacters in runTest() grep so titles with brackets/parens match literally and exactly (anchored ^…$) - index.js: add Codecept and Helper as named exports so `import { Codecept } from 'codeceptjs'` works as documented - workers.js: restore per-worker report path overrides for multiple runs, using the generic replaceValueDeep approach already in run-multiple.js. Without this, mochawesome/mocha-junit-reporter overwrite each other across browser workers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cd81b57 commit a15acc3

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ export default {
7777
}
7878

7979
// Named exports for ESM compatibility
80-
export { codecept, output, container, event, recorder, config, actor, helper, pause, within, dataTable, dataTableArgument, store, locator, heal, ai, Workers, Secret, secret, Result, Runner }
80+
export { codecept, codecept as Codecept, output, container, event, recorder, config, actor, helper, helper as Helper, pause, within, dataTable, dataTableArgument, store, locator, heal, ai, Workers, Secret, secret, Result, Runner }

lib/runner.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fsPath from 'path'
2+
import escapeRe from 'escape-string-regexp'
23
import container from './container.js'
34
import MochaFactory from './mocha/factory.js'
45
import event from './event.js'
@@ -60,7 +61,7 @@ class Runner {
6061
}
6162

6263
async runTest(test) {
63-
return this._execute({ grep: test.fullTitle })
64+
return this._execute({ grep: `^${escapeRe(test.fullTitle)}$` })
6465
}
6566

6667
async _execute({ files, grep } = {}) {

lib/workers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Codecept from './codecept.js'
1313
import MochaFactory from './mocha/factory.js'
1414
import Container from './container.js'
1515
import { getTestRoot } from './command/utils.js'
16-
import { isFunction, fileExists } from './utils.js'
16+
import { isFunction, fileExists, replaceValueDeep } from './utils.js'
1717
import mainConfig from './config.js'
1818
import output from './output.js'
1919
import event from './event.js'
@@ -119,8 +119,11 @@ const createWorkerObjects = (testGroups, config, testRoot, options, selectedRuns
119119

120120
createRuns(selectedRuns, config).forEach(worker => {
121121
const workerName = worker.name.replace(':', '_')
122-
const _config = mainConfig.applyRunConfig(config, worker.getConfig())
123-
_config.output = path.join(config.output, workerName)
122+
let _config = mainConfig.applyRunConfig(config, worker.getConfig())
123+
const workerOutput = path.join(config.output, workerName)
124+
_config = replaceValueDeep(_config, 'output', workerOutput)
125+
_config = replaceValueDeep(_config, 'reportDir', workerOutput)
126+
_config = replaceValueDeep(_config, 'mochaFile', path.join(workerOutput, `${workerName}_report.xml`))
124127
workersToExecute.push(_config)
125128
})
126129
const workers = []

0 commit comments

Comments
 (0)