Skip to content

Commit 173279c

Browse files
.
1 parent f46d557 commit 173279c

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import '../common/index.mjs';
22
import * as fixtures from '../common/fixtures.mjs';
33
import assert from 'node:assert';
4-
import { spawnSync } from 'node:child_process';
4+
import { execPath } from 'node:process';
5+
import { describe, it } from 'node:test';
56

7+
import spawn from './helper.spawnAsPromised.mjs';
68

7-
{ // Verify unadulterated source is loaded when there are no loaders
8-
const { status, stderr, stdout } = spawnSync(
9-
process.execPath,
10-
[
9+
10+
describe('ESM: ensure initialisation happens only once', { concurrency: true }, () => {
11+
it(async () => {
12+
const { code, stderr, stdout } = await spawn(execPath, [
1113
'--loader',
1214
fixtures.fileURL('es-module-loaders', 'loader-resolve-passthru.mjs'),
1315
'--no-warnings',
1416
fixtures.path('es-modules', 'runmain.mjs'),
15-
],
16-
{ encoding: 'utf8' },
17-
);
17+
]);
1818

19-
// Length minus 1 because the first match is the needle.
20-
const resolveHookRunCount = (stdout.match(/resolve passthru/g)?.length ?? 0) - 1;
19+
// Length minus 1 because the first match is the needle.
20+
const resolveHookRunCount = (stdout.match(/resolve passthru/g)?.length ?? 0) - 1;
2121

22-
assert.strictEqual(stderr, '');
23-
/**
24-
* resolveHookRunCount = 2:
25-
* 1. fixtures/…/runmain.mjs
26-
* 2. node:module (imported by fixtures/…/runmain.mjs)
27-
*/
28-
assert.strictEqual(resolveHookRunCount, 2);
29-
assert.strictEqual(status, 0);
30-
}
22+
assert.strictEqual(stderr, '');
23+
/**
24+
* resolveHookRunCount = 2:
25+
* 1. fixtures/…/runmain.mjs
26+
* 2. node:module (imported by fixtures/…/runmain.mjs)
27+
*/
28+
assert.strictEqual(resolveHookRunCount, 2);
29+
assert.strictEqual(code, 0);
30+
});
31+
});

0 commit comments

Comments
 (0)