Skip to content

Commit

Permalink
test using runner config
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham9411 committed Nov 6, 2023
1 parent 53a158b commit 4eae273
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/parallel/test-runner-cli-timeout.js
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,/);
});

0 comments on commit 4eae273

Please sign in to comment.