diff --git a/test/es-module/test-esm-dynamic-import-assertion.mjs b/test/es-module/test-esm-dynamic-import-assertion.mjs index 738fc965f5a064..605f623c15fd89 100644 --- a/test/es-module/test-esm-dynamic-import-assertion.mjs +++ b/test/es-module/test-esm-dynamic-import-assertion.mjs @@ -2,32 +2,40 @@ import '../common/index.mjs'; import { rejects, strictEqual } from 'assert'; -const jsModuleUrl = 'data:text/javascript,export{}'; +const jsModuleDataUrl = 'data:text/javascript,export{}'; await rejects( - import(`data:text/javascript,import${JSON.stringify(jsModuleUrl)}assert{type:"json"}`), + import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}assert{type:"json"}`), { code: 'ERR_FAILED_IMPORT_ASSERTION' } ); await rejects( - import(jsModuleUrl, {assert:{type:'json'}}), + import(jsModuleDataUrl, { assert: { type: 'json' } }), { code: 'ERR_FAILED_IMPORT_ASSERTION' } ); { - const secret = await import( - '../fixtures/experimental.json', - {assert: { type: 'json' }} - ); + const [secret0, secret1] = await Promise.all([ + import('../fixtures/experimental.json'), + import( + '../fixtures/experimental.json', + { assert: { type: 'json' } } + ), + ]); - strictEqual(secret.default.ofLife, 42); + strictEqual(secret0.default.ofLife, 42); + strictEqual(secret1.default.ofLife, 42); } { - const secret = await import( - 'data:application/json,{"ofLife":42}', - {assert: { type: 'json' }} - ); + const [secret0, secret1] = await Promise.all([ + import('data:application/json,{"ofLife":42}'), + import( + 'data:application/json,{"ofLife":42}', + { assert: { type: 'json' } } + ), + ]); - strictEqual(secret.default.ofLife, 42); + strictEqual(secret0.default.ofLife, 42); + strictEqual(secret1.default.ofLife, 42); } diff --git a/test/es-module/test-esm-import-assertion-3.mjs b/test/es-module/test-esm-import-assertion-3.mjs new file mode 100644 index 00000000000000..b523b11c524896 --- /dev/null +++ b/test/es-module/test-esm-import-assertion-3.mjs @@ -0,0 +1,9 @@ +// Flags: --experimental-json-modules +import '../common/index.mjs'; +import { strictEqual } from 'assert'; + +import secret0 from '../fixtures/experimental.json' assert { type: 'json' }; +import secret1 from '../fixtures/experimental.json'; + +strictEqual(secret0.ofLife, 42); +strictEqual(secret1.ofLife, 42);