mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
603e55d94d
PR-URL: https://github.com/nodejs/node/pull/55471 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import { mustNotCall } from '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import assert from 'assert';
|
|
|
|
Object.defineProperty(Error.prototype, 'url', {
|
|
get: mustNotCall('get %Error.prototype%.url'),
|
|
set: mustNotCall('set %Error.prototype%.url'),
|
|
});
|
|
Object.defineProperty(Object.prototype, 'url', {
|
|
get: mustNotCall('get %Object.prototype%.url'),
|
|
set: mustNotCall('set %Object.prototype%.url'),
|
|
});
|
|
|
|
await assert.rejects(import('../fixtures/es-modules/pjson-main'), {
|
|
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
|
|
url: fixtures.fileURL('es-modules/pjson-main').href,
|
|
});
|
|
await assert.rejects(import(`data:text/javascript,import${encodeURIComponent(JSON.stringify(fixtures.fileURL('es-modules/pjson-main')))}`), {
|
|
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
|
|
url: fixtures.fileURL('es-modules/pjson-main').href,
|
|
});
|
|
await assert.rejects(import(`data:text/javascript,import${encodeURIComponent(JSON.stringify(fixtures.fileURL('es-modules/does-not-exist')))}`), {
|
|
code: 'ERR_MODULE_NOT_FOUND',
|
|
url: fixtures.fileURL('es-modules/does-not-exist').href,
|
|
});
|
|
|
|
assert.deepStrictEqual(
|
|
{ ...await import('../fixtures/es-modules/pjson-main/main.mjs') },
|
|
{ main: 'main' },
|
|
);
|