Skip to content

Commit 8254737

Browse files
authored
fix(runner): suite timeout does not take effect (#3455)
1 parent 1988fcb commit 8254737

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

packages/runner/src/suite.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
6767
if (typeof options === 'number')
6868
options = { timeout: options }
6969

70-
// inherit repeats and retry from suite
70+
// inherit repeats, retry, timeout from suite
7171
if (typeof suiteOptions === 'object') {
7272
options = {
7373
repeats: suiteOptions.repeats,
7474
retry: suiteOptions.retry,
75+
timeout: suiteOptions.timeout,
7576
...options,
7677
}
7778
}

test/core/test/timeout.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { describe, expect, test } from 'vitest'
2+
3+
describe('suite timeout', () => {
4+
test('true is true after 5100ms', async () => {
5+
await new Promise(resolve => setTimeout(resolve, 5100))
6+
expect(true).toBe(true)
7+
})
8+
}, {
9+
timeout: 6000,
10+
})
11+
12+
describe('suite timeout simple input', () => {
13+
test('true is true after 5100ms', async () => {
14+
await new Promise(resolve => setTimeout(resolve, 5100))
15+
expect(true).toBe(true)
16+
})
17+
}, 6000)
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
import { test } from 'vitest'
1+
import { suite, test } from 'vitest'
22

33
test('hi', async () => {
44
await new Promise(resolve => setTimeout(resolve, 1000))
55
}, 10)
6+
7+
suite('suite timeout', () => {
8+
test('hi', async () => {
9+
await new Promise(resolve => setTimeout(resolve, 500))
10+
})
11+
}, {
12+
timeout: 100,
13+
})
14+
15+
suite('suite timeout simple input', () => {
16+
test('hi', async () => {
17+
await new Promise(resolve => setTimeout(resolve, 500))
18+
})
19+
}, 200)

test/fails/test/__snapshots__/runner.test.ts.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ TypeError: failure
3636
TypeError: failure"
3737
`;
3838
39-
exports[`should fail test-timeout.test.ts > test-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`;
39+
exports[`should fail test-timeout.test.ts > test-timeout.test.ts 1`] = `
40+
"Error: Test timed out in 200ms.
41+
Error: Test timed out in 100ms.
42+
Error: Test timed out in 10ms."
43+
`;
4044
4145
exports[`should fail unhandled.test.ts > unhandled.test.ts 1`] = `
4246
"Error: some error

0 commit comments

Comments
 (0)