Skip to content

Commit 2f30145

Browse files
Update test/module-hooks/test-module-hooks-builtin-require.js
Co-authored-by: Joyee Cheung <[email protected]>
1 parent 1122018 commit 2f30145

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/module-hooks/test-module-hooks-builtin-require.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ for (const mod of schemelessBlockList) {
2323

2424
const hook = registerHooks({
2525
resolve: common.mustCall((specifier, context, nextResolve) => nextResolve(specifier, context), testModules.length),
26-
load: common.mustCall((url, context, nextLoad) => nextLoad(url, context), testModules.length),
26+
const hook = registerHooks({
27+
load: common.mustCall(function load(url, context, nextLoad) {
28+
assert.match(url, /^node:/);
29+
assert.strictEqual(schemelessBlockList.has(url.slice(5, url.length)), true);
30+
const result = nextLoad(url, context);
31+
assert.strictEqual(result.source, null);
32+
return {
33+
source: 'throw new Error("I should not be thrown because the loader ignores user-supplied source for builtins")',
34+
format: 'builtin',
35+
};
36+
}, testModules.length),
37+
});
2738
});
2839

2940
for (const mod of testModules) {

0 commit comments

Comments
 (0)