MCPcopy Index your code
hub / github.com/nodejs/node / testLoader

Function testLoader

test/es-module/test-vm-main-context-default-loader.js:43–71  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

41}
42
43async function testLoader(options) {
44 {
45 // Import built-in modules
46 const script = new Script('import("fs")', options);
47 let result = await script.runInThisContext();
48 assert.strictEqual(result.constants.F_OK, fs.constants.F_OK);
49
50 const imported = compileFunction('return import("fs")', [], options)();
51 result = await imported;
52 assert.strictEqual(result.constants.F_OK, fs.constants.F_OK);
53 }
54
55 const moduleUrl = fixtures.fileURL('es-modules', 'message.mjs');
56 fs.copyFileSync(moduleUrl, tmpdir.resolve('message.mjs'));
57
58 {
59 const namespace = await import(moduleUrl);
60 const script = new Script('import("./message.mjs")', options);
61 const result = await script.runInThisContext();
62 assert.deepStrictEqual(result, namespace);
63 }
64
65 {
66 const namespace = await import(moduleUrl);
67 const imported = compileFunction('return import("./message.mjs")', [], options)();
68 const result = await imported;
69 assert.deepStrictEqual(result, namespace);
70 }
71}
72
73async function main() {
74 {

Callers 1

mainFunction · 0.85

Calls 4

runInThisContextMethod · 0.95
compileFunctionFunction · 0.85
copyFileSyncMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…