-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53a158b
commit 4eae273
Showing
1 changed file
with
12 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
'use strict'; | ||
require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const assert = require('node:assert'); | ||
const { spawnSync } = require('node:child_process'); | ||
const { test } = require('node:test'); | ||
const cwd = fixtures.path('test-runner', 'default-behavior'); | ||
const env = { ...process.env, 'NODE_DEBUG': 'test_runner' }; | ||
|
||
test('test-timeout flag', () => { | ||
const args = ['--test', '--test-timeout', 10, 'test/fixtures/test-runner/never_ending_sync.js']; | ||
const child = spawnSync(process.execPath, args, { timeout: 500 }); | ||
test('default timeout -- Infinity', async () => { | ||
const args = ['--test']; | ||
const cp = spawnSync(process.execPath, args, { cwd, env }); | ||
assert.match(cp.stderr.toString(), /timeout: Infinity,/); | ||
}); | ||
|
||
assert.strictEqual(child.status, 1); | ||
assert.strictEqual(child.signal, null); | ||
assert.strictEqual(child.stderr.toString(), ''); | ||
const stdout = child.stdout.toString(); | ||
assert.match(stdout, /not ok 1 - test/); | ||
assert.match(stdout, / {2}---/); | ||
assert.match(stdout, / {2}duration_ms: .*/); | ||
assert.match(stdout, /failureType: 'testTimeoutFailure/); | ||
assert.match(stdout, /error: 'test timed out after 10ms'/); | ||
test('timeout of 10ms', async () => { | ||
const args = ['--test', '--test-timeout', 10]; | ||
const cp = spawnSync(process.execPath, args, { cwd, env }); | ||
assert.match(cp.stderr.toString(), /timeout: 10,/); | ||
}); |