Skip to content

Commit 07863c5

Browse files
committed
fixup! reduce test timeout and improve test desc
1 parent c1f5562 commit 07863c5

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

test/fixtures/test-runner/output/test-timeout-flag.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ const { describe, test } = require('node:test');
44
const { setTimeout } = require('node:timers/promises');
55

66
describe('--test-timeout is set to 20ms', () => {
7-
test('test 1 must fail due to testTimeoutFailure with error test timed out after 20ms', async () => {
8-
await setTimeout(1000);
9-
})
10-
test('test 2 must fail due to testTimeoutFailure with error test timed out after 600ms', { timeout: 600 }, async () => {
11-
await setTimeout(1000);
12-
})
13-
test('test 3 must pass', async () => {
7+
test('should timeout after 20ms', async () => {
8+
await setTimeout(100);
9+
});
10+
test('should timeout after 5ms', { timeout: 5 }, async () => {
11+
await setTimeout(100);
12+
});
13+
test('should not timeout', { timeout: 50 }, async () => {
14+
await setTimeout(25);
15+
});
16+
test('should pass', async () => {
1417
await setTimeout(10);
15-
})
18+
});
1619
});

test/fixtures/test-runner/output/test-timeout-flag.snapshot

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TAP version 13
22
# Subtest: --test-timeout is set to 20ms
3-
# Subtest: test 1 must fail due to testTimeoutFailure with error test timed out after 20ms
4-
not ok 1 - test 1 must fail due to testTimeoutFailure with error test timed out after 20ms
3+
# Subtest: should timeout after 20ms
4+
not ok 1 - should timeout after 20ms
55
---
66
duration_ms: *
77
type: 'test'
@@ -12,23 +12,29 @@ TAP version 13
1212
stack: |-
1313
async Promise.all (index 0)
1414
...
15-
# Subtest: test 2 must fail due to testTimeoutFailure with error test timed out after 600ms
16-
not ok 2 - test 2 must fail due to testTimeoutFailure with error test timed out after 600ms
15+
# Subtest: should timeout after 5ms
16+
not ok 2 - should timeout after 5ms
1717
---
1818
duration_ms: *
1919
type: 'test'
2020
location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):3'
2121
failureType: 'testTimeoutFailure'
22-
error: 'test timed out after 600ms'
22+
error: 'test timed out after 5ms'
2323
code: 'ERR_TEST_FAILURE'
2424
...
25-
# Subtest: test 3 must pass
26-
ok 3 - test 3 must pass
25+
# Subtest: should not timeout
26+
ok 3 - should not timeout
2727
---
2828
duration_ms: *
2929
type: 'test'
3030
...
31-
1..3
31+
# Subtest: should pass
32+
ok 4 - should pass
33+
---
34+
duration_ms: *
35+
type: 'test'
36+
...
37+
1..4
3238
not ok 1 - --test-timeout is set to 20ms
3339
---
3440
duration_ms: *
@@ -39,9 +45,9 @@ not ok 1 - --test-timeout is set to 20ms
3945
code: 'ERR_TEST_FAILURE'
4046
...
4147
1..1
42-
# tests 3
48+
# tests 4
4349
# suites 1
44-
# pass 1
50+
# pass 2
4551
# fail 0
4652
# cancelled 2
4753
# skipped 0

0 commit comments

Comments
 (0)