mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
3d5357a2f4
This commit updates the test runner tests in order to switch the default reporter from tap to spec. This commit can be backported, while changing the default reporter cannot. Refs: https://github.com/nodejs/node/issues/54540 PR-URL: https://github.com/nodejs/node/pull/54547 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
const { setTimeout } = require('timers/promises');
|
|
|
|
if (process.argv[2] === 'child') {
|
|
const test = require('node:test');
|
|
|
|
if (process.argv[3] === 'abortSignal') {
|
|
assert.throws(() => test({ signal: {} }), {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError'
|
|
});
|
|
|
|
let testSignal;
|
|
test({ timeout: 10 }, common.mustCall(async ({ signal }) => {
|
|
assert.strictEqual(signal.aborted, false);
|
|
testSignal = signal;
|
|
await setTimeout(50);
|
|
})).finally(common.mustCall(() => {
|
|
test(() => assert.strictEqual(testSignal.aborted, true));
|
|
}));
|
|
|
|
// TODO(benjamingr) add more tests to describe + AbortSignal
|
|
// this just tests the parameter is passed
|
|
test.describe('Abort Signal in describe', common.mustCall(({ signal }) => {
|
|
test.it('Supports AbortSignal', () => {
|
|
assert.strictEqual(signal.aborted, false);
|
|
});
|
|
}));
|
|
} else assert.fail('unreachable');
|
|
} else {
|
|
const child = spawnSync(process.execPath, [__filename, 'child', 'abortSignal']);
|
|
const stdout = child.stdout.toString();
|
|
assert.match(stdout, /pass 2$/m);
|
|
assert.match(stdout, /fail 0$/m);
|
|
assert.match(stdout, /cancelled 1$/m);
|
|
assert.strictEqual(child.status, 1);
|
|
assert.strictEqual(child.signal, null);
|
|
}
|