Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runner): suite timeout does not take effect #3455

Merged
merged 5 commits into from May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/runner/src/suite.ts
Expand Up @@ -67,11 +67,12 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
if (typeof options === 'number')
options = { timeout: options }

// inherit repeats and retry from suite
// inherit repeats, retry, timeout from suite
if (typeof suiteOptions === 'object') {
options = {
repeats: suiteOptions.repeats,
retry: suiteOptions.retry,
timeout: suiteOptions.timeout,
...options,
}
}
Expand Down
17 changes: 17 additions & 0 deletions test/core/test/timeout.spec.ts
@@ -0,0 +1,17 @@
import { describe, expect, test } from 'vitest'

describe('suite timeout', () => {
test('true is true after 5100ms', async () => {
await new Promise(resolve => setTimeout(resolve, 5100))
expect(true).toBe(true)
})
}, {
timeout: 6000,
})
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved

describe('suite timeout simple input', () => {
test('true is true after 5100ms', async () => {
await new Promise(resolve => setTimeout(resolve, 5100))
expect(true).toBe(true)
})
}, 6000)
16 changes: 15 additions & 1 deletion test/fails/fixtures/test-timeout.test.ts
@@ -1,5 +1,19 @@
import { test } from 'vitest'
import { suite, test } from 'vitest'

test('hi', async () => {
await new Promise(resolve => setTimeout(resolve, 1000))
}, 10)

suite('suite timeout', () => {
test('hi', async () => {
await new Promise(resolve => setTimeout(resolve, 500))
})
}, {
timeout: 100,
})

suite('suite timeout simple input', () => {
test('hi', async () => {
await new Promise(resolve => setTimeout(resolve, 500))
})
}, 200)
6 changes: 5 additions & 1 deletion test/fails/test/__snapshots__/runner.test.ts.snap
Expand Up @@ -36,7 +36,11 @@ TypeError: failure
TypeError: failure"
`;

exports[`should fail test-timeout.test.ts > test-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`;
exports[`should fail test-timeout.test.ts > test-timeout.test.ts 1`] = `
"Error: Test timed out in 200ms.
Error: Test timed out in 100ms.
Error: Test timed out in 10ms."
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
`;

exports[`should fail unhandled.test.ts > unhandled.test.ts 1`] = `
"Error: some error
Expand Down