Skip to content

Commit 6f0b318

Browse files
committed
Fix: Only auto-exit when using browser helpers to prevent timeout test failures
- Auto-exit now only triggers when Playwright/Puppeteer/WebDriver helpers are loaded - Prevents interference with timeout tests that don't use browser helpers - Fixes 4 failing tests in test:runner (timeout tests) - Maintains fix for browser helper process hanging
1 parent ba578e4 commit 6f0b318

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/command/run.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getConfig, printError, getTestRoot, createOutputDir } from './utils.js'
22
import Config from '../config.js'
33
import store from '../store.js'
44
import Codecept from '../codecept.js'
5+
import container from '../container.js'
56

67
export default async function (test, options) {
78
// registering options globally to use in config
@@ -43,12 +44,18 @@ export default async function (test, options) {
4344
} finally {
4445
await codecept.teardown()
4546

46-
// Schedule a delayed exit to prevent process hanging due to helper event loops (e.g., Playwright)
47+
// Schedule a delayed exit to prevent process hanging due to browser helper event loops
48+
// Only needed for Playwright/Puppeteer which keep the event loop alive
4749
// Wait 1 second to allow final cleanup and output to complete
4850
if (!process.env.CODECEPT_DISABLE_AUTO_EXIT) {
49-
setTimeout(() => {
50-
process.exit(process.exitCode || 0)
51-
}, 1000).unref()
51+
const helpers = container.helpers()
52+
const hasBrowserHelper = helpers && (helpers.Playwright || helpers.Puppeteer || helpers.WebDriver)
53+
54+
if (hasBrowserHelper) {
55+
setTimeout(() => {
56+
process.exit(process.exitCode || 0)
57+
}, 1000).unref()
58+
}
5259
}
5360
}
5461
}

0 commit comments

Comments
 (0)