Skip to content

Commit 7b15b82

Browse files
committed
fix test:runner
1 parent a8d9bb7 commit 7b15b82

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/rerun.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const require = createRequire(import.meta.url)
1010
class CodeceptRerunner extends BaseCodecept {
1111
async runOnce(test) {
1212
await container.started()
13-
13+
1414
// Ensure translations are loaded for Gherkin features
1515
try {
1616
const { loadTranslations } = await import('./mocha/gherkin.js')
@@ -25,19 +25,19 @@ class CodeceptRerunner extends BaseCodecept {
2525
// @ts-ignore
2626
container.createMocha()
2727
const mocha = container.mocha()
28-
28+
2929
let filesToRun = this.testFiles
3030
if (test) {
3131
if (!fsPath.isAbsolute(test)) {
3232
test = fsPath.join(global.codecept_dir, test)
3333
}
3434
filesToRun = this.testFiles.filter(t => fsPath.basename(t, '.js') === test || t === test)
3535
}
36-
36+
3737
// Clear any existing tests/suites
3838
mocha.suite.suites = []
3939
mocha.suite.tests = []
40-
40+
4141
// Manually load each test file by importing it
4242
for (const file of filesToRun) {
4343
try {
@@ -47,19 +47,25 @@ class CodeceptRerunner extends BaseCodecept {
4747
} catch (e) {
4848
// ESM modules don't have require.cache, ignore
4949
}
50-
50+
5151
// Force reload the module by using a cache-busting query parameter
5252
const fileUrl = `${fsPath.resolve(file)}?t=${Date.now()}`
5353
await import(fileUrl)
5454
} catch (e) {
5555
console.error(`Error loading test file ${file}:`, e)
5656
}
5757
}
58-
58+
5959
const done = () => {
6060
event.emit(event.all.result, container.result())
6161
event.emit(event.all.after, this)
62-
resolve(undefined)
62+
63+
// Check if there were any failures
64+
if (container.result().hasFailed) {
65+
reject(new Error('Test run failed'))
66+
} else {
67+
resolve(undefined)
68+
}
6369
}
6470

6571
event.emit(event.all.before, this)

0 commit comments

Comments
 (0)