From 2689c9ed86912b0be5371bbe3638c3cf893cf96f Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 27 May 2023 09:17:03 +0800 Subject: [PATCH 1/4] fix(runner): suite timeout does not take effect --- packages/runner/src/suite.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/runner/src/suite.ts b/packages/runner/src/suite.ts index 231048970e4f..0ab84ab18d72 100644 --- a/packages/runner/src/suite.ts +++ b/packages/runner/src/suite.ts @@ -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, } } From 5ed919edd65f38b204d3e65cf7531704e8f9f71d Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 27 May 2023 16:00:44 +0800 Subject: [PATCH 2/4] test: add timeout test case --- test/core/test/timeout.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 test/core/test/timeout.spec.ts diff --git a/test/core/test/timeout.spec.ts b/test/core/test/timeout.spec.ts new file mode 100644 index 000000000000..834b3d8b2258 --- /dev/null +++ b/test/core/test/timeout.spec.ts @@ -0,0 +1,10 @@ +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, +}) From 16b34820fe8ba83fa4f07e37ca6cee56a1b23485 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 29 May 2023 21:53:40 +0800 Subject: [PATCH 3/4] test: update test --- test/core/test/timeout.spec.ts | 7 +++++++ test/fails/fixtures/test-timeout.test.ts | 16 +++++++++++++++- .../fails/test/__snapshots__/runner.test.ts.snap | 5 ++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/test/core/test/timeout.spec.ts b/test/core/test/timeout.spec.ts index 834b3d8b2258..321f01ea721b 100644 --- a/test/core/test/timeout.spec.ts +++ b/test/core/test/timeout.spec.ts @@ -8,3 +8,10 @@ describe('suite timeout', () => { }, { timeout: 6000, }) + +describe('suite timeout simple input', () => { + test('true is true after 5100ms', async () => { + await new Promise(resolve => setTimeout(resolve, 5100)) + expect(true).toBe(true) + }) +}, 6000) diff --git a/test/fails/fixtures/test-timeout.test.ts b/test/fails/fixtures/test-timeout.test.ts index 8b90a52359ae..1e631a812517 100644 --- a/test/fails/fixtures/test-timeout.test.ts +++ b/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)) + }) +}, 100) diff --git a/test/fails/test/__snapshots__/runner.test.ts.snap b/test/fails/test/__snapshots__/runner.test.ts.snap index 66dbe981fe39..7c4c9e202cfc 100644 --- a/test/fails/test/__snapshots__/runner.test.ts.snap +++ b/test/fails/test/__snapshots__/runner.test.ts.snap @@ -36,7 +36,10 @@ TypeError: failure TypeError: failure" `; -exports[`should fails > test-timeout.test.ts > test-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`; +exports[`should fails > test-timeout.test.ts > test-timeout.test.ts 1`] = ` +"Error: Test timed out in 100ms. +Error: Test timed out in 10ms." +`; exports[`should fails > unhandled.test.ts > unhandled.test.ts 1`] = ` "Error: some error From d89aa005bbfc376baa746e80f7228a07c6070712 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 29 May 2023 22:10:43 +0800 Subject: [PATCH 4/4] test: update timeout --- test/fails/fixtures/test-timeout.test.ts | 2 +- test/fails/test/__snapshots__/runner.test.ts.snap | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/fails/fixtures/test-timeout.test.ts b/test/fails/fixtures/test-timeout.test.ts index 1e631a812517..f67add79b8b4 100644 --- a/test/fails/fixtures/test-timeout.test.ts +++ b/test/fails/fixtures/test-timeout.test.ts @@ -16,4 +16,4 @@ suite('suite timeout simple input', () => { test('hi', async () => { await new Promise(resolve => setTimeout(resolve, 500)) }) -}, 100) +}, 200) diff --git a/test/fails/test/__snapshots__/runner.test.ts.snap b/test/fails/test/__snapshots__/runner.test.ts.snap index 05442e459e9d..ac8c44666374 100644 --- a/test/fails/test/__snapshots__/runner.test.ts.snap +++ b/test/fails/test/__snapshots__/runner.test.ts.snap @@ -36,8 +36,9 @@ TypeError: failure TypeError: failure" `; -exports[`should fails > test-timeout.test.ts > test-timeout.test.ts 1`] = ` -"Error: Test timed out in 100ms. +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." `;