mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
f5f67ae4a7
This commit updates the way the test runner processes 'only' tests when process-based test isolation is disabled. The --test-only flag is no longer necessary in this scenario. The test runner will automatically detect 'only' tests and apply the appropriate filtering. PR-URL: https://github.com/nodejs/node/pull/54832 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
import * as common from '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { test } from 'node:test';
|
|
|
|
const testArguments = [
|
|
'--test',
|
|
'--experimental-test-isolation=none',
|
|
];
|
|
|
|
const testFiles = [
|
|
fixtures.path('test-runner', 'no-isolation', 'one.test.js'),
|
|
fixtures.path('test-runner', 'no-isolation', 'two.test.js'),
|
|
];
|
|
|
|
const order = [
|
|
'before(): global',
|
|
|
|
'before one: <root>',
|
|
'suite one',
|
|
|
|
'before two: <root>',
|
|
'suite two',
|
|
|
|
'beforeEach(): global',
|
|
'beforeEach one: suite one - test',
|
|
'beforeEach two: suite one - test',
|
|
|
|
'suite one - test',
|
|
'afterEach(): global',
|
|
'afterEach one: suite one - test',
|
|
'afterEach two: suite one - test',
|
|
|
|
'before suite two: suite two',
|
|
'beforeEach(): global',
|
|
'beforeEach one: suite two - test',
|
|
'beforeEach two: suite two - test',
|
|
|
|
'suite two - test',
|
|
'afterEach(): global',
|
|
'afterEach one: suite two - test',
|
|
'afterEach two: suite two - test',
|
|
|
|
'after(): global',
|
|
'after one: <root>',
|
|
'after two: <root>',
|
|
];
|
|
|
|
test('Using --require to define global hooks works', async (t) => {
|
|
const spawned = await common.spawnPromisified(process.execPath, [
|
|
...testArguments,
|
|
'--require', fixtures.path('test-runner', 'no-isolation', 'global-hooks.js'),
|
|
...testFiles,
|
|
]);
|
|
|
|
t.assert.ok(spawned.stdout.includes(order.join('\n')));
|
|
});
|
|
|
|
test('Using --import to define global hooks works', async (t) => {
|
|
const spawned = await common.spawnPromisified(process.execPath, [
|
|
...testArguments,
|
|
'--import', fixtures.fileURL('test-runner', 'no-isolation', 'global-hooks.js'),
|
|
...testFiles,
|
|
]);
|
|
|
|
t.assert.ok(spawned.stdout.includes(order.join('\n')));
|
|
});
|