mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 21:46:48 +00:00

Some checks are pending
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
PR-URL: https://github.com/nodejs/node/pull/57595 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
71 lines
1.7 KiB
JavaScript
71 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',
|
|
'--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>',
|
|
].join('\n');
|
|
|
|
test('use --import (CJS) to define global hooks', async (t) => {
|
|
const { stdout } = await common.spawnPromisified(process.execPath, [
|
|
...testArguments,
|
|
'--import', fixtures.fileURL('test-runner', 'no-isolation', 'global-hooks.cjs'),
|
|
...testFiles,
|
|
]);
|
|
|
|
const testHookOutput = stdout.split('\n▶')[0];
|
|
|
|
t.assert.equal(testHookOutput, order);
|
|
});
|
|
|
|
test('use --import (ESM) to define global hooks', async (t) => {
|
|
const { stdout } = await common.spawnPromisified(process.execPath, [
|
|
...testArguments,
|
|
'--import', fixtures.fileURL('test-runner', 'no-isolation', 'global-hooks.mjs'),
|
|
...testFiles,
|
|
]);
|
|
|
|
const testHookOutput = stdout.split('\n▶')[0];
|
|
|
|
t.assert.equal(testHookOutput, order);
|
|
});
|