Skip to content

Commit c4b3090

Browse files
committed
Fix coverage output - properly await async done() callback
- Mocha callback wasn't awaiting the async done() function - Changed mocha.run(() => done()) to mocha.run(async () => await done()) - Added error handling to coverage generation - This ensures recorder tasks in event.all.after complete before process exit
1 parent 0ef76fd commit c4b3090

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/codecept.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class Codecept {
279279

280280
try {
281281
event.emit(event.all.before, this)
282-
mocha.run(() => done())
282+
mocha.run(async () => await done())
283283
} catch (e) {
284284
output.error(e.stack)
285285
reject(e)

lib/plugin/coverage.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,13 @@ export default function (config) {
154154
recorder.add(
155155
'generate coverage report',
156156
async () => {
157-
output.print(`writing ${coverageOptions.outputDir}`)
158-
await coverageReport.generate()
157+
try {
158+
output.print(`writing ${coverageOptions.outputDir}`)
159+
await coverageReport.generate()
160+
} catch (error) {
161+
output.print(`Failed to generate coverage report: ${error.message}`)
162+
// Don't throw - coverage failure shouldn't fail tests
163+
}
159164
},
160165
true,
161166
false,

0 commit comments

Comments
 (0)