node/test/module-hooks/test-async-loader-hooks-globalpreload-no-warning-with-initialize.mjs
Joyee Cheung 3da4dce296
test: split test-esm-loader-hooks
Previously whenever one of the test case fails in the CI, it
barely logged anything useful in the CI and it was difficult to
nail down the specific failing case with a local reproduction,
especially when the test fixutre is inline JavaScript. This patch:

- Puts all the inline JavaScript in on-disk fixtures so that
  they can be re-run easily.
- Split the tests into individual files so that it's easier to nail
  down the failure
- Use spawnSyncAndAssert which logs useful information when the child
  process does not behave as expected.
- Rename the tests as module-hooks/test-async-loader-hooks-* because
  they belong to the module hooks test suite and are not esm-specific.

PR-URL: https://github.com/nodejs/node/pull/61374
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-01-13.md
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-01-16 14:30:12 +00:00

21 lines
622 B
JavaScript

// Test that `globalPreload` should not emit warning when `initialize` is supplied
import '../common/index.mjs';
import assert from 'node:assert';
import { execPath } from 'node:process';
import fixtures from '../common/fixtures.js';
import { spawnSyncAndAssert } from '../common/child_process.js';
spawnSyncAndAssert(
execPath,
[
'--experimental-loader',
fixtures.fileURL('es-module-loaders/loader-globalpreload-and-initialize.mjs'),
fixtures.path('empty.js'),
],
{
stderr(output) {
assert.doesNotMatch(output, /`globalPreload` has been removed; use `initialize` instead/);
},
},
);