-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: add timeout support to test plan
- Loading branch information
Showing
4 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/fixtures/test-runner/output/test-runner-plan-timeout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
const { describe, it } = require('node:test'); | ||
const { setTimeout } = require('node:timers/promises'); | ||
|
||
describe('planning with timeout', () => { | ||
it(`planning should pass if plan it's correct`, async (t) => { | ||
t.plan(1, { timeout: 500_000_000 }); | ||
t.assert.ok(true); | ||
}); | ||
|
||
it(`planning should fail if plan it's incorrect`, async (t) => { | ||
t.plan(1, { timeout: 500_000_000 }); | ||
t.assert.ok(true); | ||
t.assert.ok(true); | ||
}); | ||
|
||
it('planning with timeout', async (t) => { | ||
t.plan(1, { timeout: 2000 }); | ||
|
||
while (true) { | ||
await setTimeout(5000); | ||
} | ||
}); | ||
|
||
it('nested planning with timeout', async (t) => { | ||
t.plan(1, { timeout: 2000 }); | ||
|
||
t.test('nested', async (t) => { | ||
while (true) { | ||
await setTimeout(5000); | ||
} | ||
}); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
test/fixtures/test-runner/output/test-runner-plan-timeout.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
TAP version 13 | ||
# Subtest: planning with timeout | ||
# Subtest: planning should pass if plan it's correct | ||
ok 1 - planning should pass if plan it's correct | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
... | ||
# Subtest: planning should fail if plan it's incorrect | ||
not ok 2 - planning should fail if plan it's incorrect | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
location: '/test/fixtures/test-runner/output/test-runner-plan-timeout.js:(LINE):3' | ||
failureType: 'testCodeFailure' | ||
error: 'plan expected 1 assertions but received 2' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
# Subtest: planning with timeout | ||
not ok 3 - planning with timeout | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
location: '/test/fixtures/test-runner/output/test-runner-plan-timeout.js:(LINE):3' | ||
failureType: 'testTimeoutFailure' | ||
error: 'plan timed out after 2000ms with 0 assertions when expecting 1' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
# Subtest: nested planning with timeout | ||
# Subtest: nested | ||
not ok 1 - nested | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
location: '/test/fixtures/test-runner/output/test-runner-plan-timeout.js:(LINE):7' | ||
failureType: 'cancelledByParent' | ||
error: 'test did not finish before its parent and was cancelled' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
1..1 | ||
not ok 4 - nested planning with timeout | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
location: '/test/fixtures/test-runner/output/test-runner-plan-timeout.js:(LINE):3' | ||
failureType: 'subtestsFailed' | ||
error: '1 subtest failed' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
1..4 | ||
not ok 1 - planning with timeout | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
location: '/test/fixtures/test-runner/output/test-runner-plan-timeout.js:(LINE):1' | ||
failureType: 'subtestsFailed' | ||
error: '3 subtests failed' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
1..1 | ||
# tests 5 | ||
# suites 1 | ||
# pass 1 | ||
# fail 2 | ||
# cancelled 2 | ||
# skipped 0 | ||
# todo 0 | ||
# duration_ms * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters