-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
test_runner: improve --test-timeout to be per test #57672
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
Merged
nodejs-github-bot
merged 10 commits into
nodejs:main
from
jakecastelli:test-timeout-improvement
Apr 9, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c1c48ec
test_runner: improve --test-timeout to be per test
jakecastelli c1f5562
fixup! change timeout to 20ms and format the file
jakecastelli 07863c5
fixup! reduce test timeout and improve test desc
jakecastelli 180116b
fixup! hoist timeoutPerTest out of if
jakecastelli af2201e
address PR comments
jakecastelli 6559293
remove deuplicated if checks and move this.timeout into FileTest and …
jakecastelli 24a1936
fixup! fix tests
jakecastelli 04f280b
fixup! address more comments
jakecastelli ab0e86a
fixup! incorrect logic for cli timeout to take precedent
jakecastelli 44c7757
fixup! linting error
jakecastelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,19 @@ | ||
// Flags: --test-timeout=20 | ||
'use strict'; | ||
const { describe, test } = require('node:test'); | ||
const { setTimeout } = require('node:timers/promises'); | ||
|
||
describe('--test-timeout is set to 20ms', () => { | ||
jakecastelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test('should timeout after 20ms', async () => { | ||
await setTimeout(200000, undefined, { ref: false }); | ||
}); | ||
test('should timeout after 5ms', { timeout: 5 }, async () => { | ||
await setTimeout(200000, undefined, { ref: false }); | ||
}); | ||
|
||
test('should not timeout', { timeout: 50000 }, async () => { | ||
await setTimeout(1); | ||
}); | ||
|
||
test('should pass', async () => {}); | ||
}); |
55 changes: 55 additions & 0 deletions
55
test/fixtures/test-runner/output/test-timeout-flag.snapshot
This file contains hidden or 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,55 @@ | ||
TAP version 13 | ||
# Subtest: --test-timeout is set to 20ms | ||
# Subtest: should timeout after 20ms | ||
not ok 1 - should timeout after 20ms | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):3' | ||
failureType: 'testTimeoutFailure' | ||
error: 'test timed out after 20ms' | ||
code: 'ERR_TEST_FAILURE' | ||
stack: |- | ||
async Promise.all (index 0) | ||
... | ||
# Subtest: should timeout after 5ms | ||
not ok 2 - should timeout after 5ms | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):3' | ||
failureType: 'testTimeoutFailure' | ||
error: 'test timed out after 5ms' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
# Subtest: should not timeout | ||
ok 3 - should not timeout | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
... | ||
# Subtest: should pass | ||
ok 4 - should pass | ||
--- | ||
duration_ms: * | ||
type: 'test' | ||
... | ||
1..4 | ||
not ok 1 - --test-timeout is set to 20ms | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):1' | ||
failureType: 'subtestsFailed' | ||
error: '2 subtests failed' | ||
code: 'ERR_TEST_FAILURE' | ||
... | ||
1..1 | ||
# tests 4 | ||
# suites 1 | ||
# pass 2 | ||
# fail 0 | ||
# cancelled 2 | ||
# skipped 0 | ||
# todo 0 | ||
pmarchini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# duration_ms * |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.