This commit introduces a new --experimental-test-isolation flag that, when set to 'none', causes the test runner to execute all tests in the same process. By default, this is the main test runner process, but if watch mode is enabled, it spawns a separate process that runs all of the tests. The default value of the new flag is 'process', which uses the existing behavior of running each test file in its own child process. It is worth noting that when the isolation mode is 'none', globals and all other top level logic (such as top level before() and after() hooks) is shared among all files. Co-authored-by: Moshe Atlow <moshe@atlow.co.il> PR-URL: https://github.com/nodejs/node/pull/53927 Fixes: https://github.com/nodejs/node/issues/51548 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import { allowGlobals, mustCall, mustNotCall } from '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { deepStrictEqual } from 'node:assert';
|
|
import { run } from 'node:test';
|
|
|
|
const stream = run({
|
|
files: [
|
|
fixtures.path('test-runner', 'no-isolation', 'one.test.js'),
|
|
fixtures.path('test-runner', 'no-isolation', 'two.test.js'),
|
|
],
|
|
isolation: 'none',
|
|
});
|
|
|
|
stream.on('test:fail', mustNotCall());
|
|
stream.on('test:pass', mustCall(5));
|
|
// eslint-disable-next-line no-unused-vars
|
|
for await (const _ of stream);
|
|
allowGlobals(globalThis.GLOBAL_ORDER);
|
|
deepStrictEqual(globalThis.GLOBAL_ORDER, [
|
|
'before one: <root>',
|
|
'suite one',
|
|
'before two: <root>',
|
|
'suite two',
|
|
|
|
'beforeEach one: suite one - test',
|
|
'beforeEach two: suite one - test',
|
|
'suite one - test',
|
|
'afterEach one: suite one - test',
|
|
'afterEach two: suite one - test',
|
|
|
|
'beforeEach one: test one',
|
|
'beforeEach two: test one',
|
|
'test one',
|
|
'afterEach one: test one',
|
|
'afterEach two: test one',
|
|
|
|
'before suite two: suite two',
|
|
|
|
'beforeEach one: suite two - test',
|
|
'beforeEach two: suite two - test',
|
|
'suite two - test',
|
|
'afterEach one: suite two - test',
|
|
'afterEach two: suite two - test',
|
|
|
|
'after one: <root>',
|
|
'after two: <root>',
|
|
]);
|