Skip to content

Commit 43977c2

Browse files
authored
fix: use suite's timeout when test.extend (#8278)
1 parent e9c9282 commit 43977c2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/runner/src/suite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ export function createTaskCollector(
786786
)
787787
}
788788
const { handler, options } = parseArguments(optionsOrFn, optionsOrTest)
789-
const timeout = options.timeout ?? runner?.config.testTimeout
789+
const timeout = options.timeout ?? collector.options?.timeout ?? runner?.config.testTimeout
790790
originalWrapper.call(context, formatName(name), handler, timeout)
791791
}, _context)
792792
}

test/core/test/test-extend.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,17 @@ describe('test.scoped repro #7813', () => {
487487
})
488488
})
489489
})
490+
491+
describe('suite with timeout', () => {
492+
test.extend({}).fails('should timeout', async () => {
493+
await new Promise(resolve => setTimeout(resolve, 1_000))
494+
})
495+
496+
test.extend({})('should pass', { timeout: 1_000 }, async () => {
497+
await new Promise(resolve => setTimeout(resolve, 200))
498+
})
499+
500+
test.extend({})('should also pass', async () => {
501+
await new Promise(resolve => setTimeout(resolve, 1))
502+
})
503+
}, 100)

0 commit comments

Comments
 (0)