Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 2112ba6

Browse files
authored
Set timeouts underhood (#119)
* Set timeouts underhood * Fix PR comments
1 parent b56437e commit 2112ba6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/PlaywrightEnvironment.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-disable @typescript-eslint/ban-ts-ignore */
33
import NodeEnvironment from 'jest-environment-node'
44
import { Config as JestConfig } from '@jest/types'
5+
import { Event, State } from 'jest-circus'
56
import {
67
getBrowserType,
78
getDeviceType,
@@ -177,6 +178,18 @@ class PlaywrightEnvironment extends NodeEnvironment {
177178
}
178179
}
179180

181+
async handleTestEvent(event: Event, state: State): Promise<void> {
182+
// Hack to set testTimeout for jestPlaywright debugging
183+
if (
184+
event.name === 'add_test' &&
185+
event.fn &&
186+
event.fn.toString().includes('jestPlaywright.debug()')
187+
) {
188+
// Set timeout to 4 days
189+
state.testTimeout = 4 * 24 * 60 * 60 * 1000
190+
}
191+
}
192+
180193
async teardown(jestConfig: JestConfig.InitialOptions = {}): Promise<void> {
181194
const { page, context, browser } = this.global
182195
if (page) {

src/PlaywrightRunner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ class PlaywrightRunner extends JestRunner {
6666
globalConfig: JestConfig.GlobalConfig,
6767
context: TestRunnerContext,
6868
) {
69-
super(globalConfig, context)
69+
const config = { ...globalConfig }
70+
// Set default timeout to 15s
71+
config.testTimeout = config.testTimeout || 15000
72+
super(config, context)
7073
}
7174

7275
async runTests(

0 commit comments

Comments
 (0)