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

Function testBasic

test/parallel/test-vm-module-import-meta.js:9–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7const { SourceTextModule } = require('vm');
8
9async function testBasic() {
10 const m = new SourceTextModule('globalThis.importMeta = import.meta;', {
11 initializeImportMeta: common.mustCall((meta, module) => {
12 assert.strictEqual(module, m);
13 meta.prop = 42;
14 })
15 });
16 await m.link(common.mustNotCall());
17 await m.evaluate();
18 const result = globalThis.importMeta;
19 delete globalThis.importMeta;
20 assert.strictEqual(typeof result, 'object');
21 assert.strictEqual(Object.getPrototypeOf(result), null);
22 assert.strictEqual(result.prop, 42);
23 assert.deepStrictEqual(Reflect.ownKeys(result), ['prop']);
24}
25
26async function testInvalid() {
27 for (const invalidValue of [

Callers 1

Calls 2

linkMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…