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

Function test

test/es-module/test-esm-import-attributes-errors.js:8–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const jsonModuleDataUrl = 'data:application/json,""';
7
8async function test() {
9 await assert.rejects(
10 import('data:text/css,', { with: { type: 'css' } }),
11 { code: 'ERR_UNKNOWN_MODULE_FORMAT' }
12 );
13
14 await assert.rejects(
15 import('data:text/css,', { with: { unsupportedAttribute: 'value' } }),
16 { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
17 );
18
19 await assert.rejects(
20 import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`),
21 { code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
22 );
23
24 await assert.rejects(
25 import(jsModuleDataUrl, { with: { type: 'json' } }),
26 { code: 'ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE' }
27 );
28
29 await assert.rejects(
30 import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }),
31 { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
32 );
33
34 await assert.rejects(
35 import(jsModuleDataUrl, { with: { type: 'unsupported' } }),
36 { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
37 );
38
39 await assert.rejects(
40 import(jsonModuleDataUrl),
41 { code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
42 );
43
44 await assert.rejects(
45 import(jsonModuleDataUrl, { with: {} }),
46 { code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
47 );
48
49 await assert.rejects(
50 import(jsonModuleDataUrl, { with: { foo: 'bar' } }),
51 { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
52 );
53
54 await assert.rejects(
55 import(jsonModuleDataUrl, { with: { type: 'unsupported' } }),
56 { code: 'ERR_IMPORT_ATTRIBUTE_UNSUPPORTED' }
57 );
58
59 await assert.rejects(
60 import(jsonModuleDataUrl, { assert: { type: 'json' } }),
61 { code: 'ERR_IMPORT_ATTRIBUTE_MISSING' }
62 );
63
64 await assert.rejects(
65 import(`data:text/javascript,import${JSON.stringify(jsonModuleDataUrl)}assert{type:"json"}`),

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…