2022-07-29 08:42:55 +00:00
|
|
|
import { spawnPromisified } from '../common/index.mjs';
|
|
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
|
|
import assert from 'node:assert';
|
|
|
|
import { execPath } from 'node:process';
|
|
|
|
import { describe, it } from 'node:test';
|
2022-01-06 11:07:52 +00:00
|
|
|
|
|
|
|
|
2024-03-23 21:11:28 +00:00
|
|
|
describe('ESM: named JSON exports', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
2022-07-29 08:42:55 +00:00
|
|
|
it('should throw, citing named import', async () => {
|
|
|
|
const { code, stderr } = await spawnPromisified(execPath, [
|
|
|
|
fixtures.path('es-modules', 'import-json-named-export.mjs'),
|
|
|
|
]);
|
|
|
|
|
|
|
|
// SyntaxError: The requested module '../experimental.json'
|
|
|
|
// does not provide an export named 'ofLife'
|
|
|
|
assert.match(stderr, /SyntaxError:/);
|
|
|
|
assert.match(stderr, /'\.\.\/experimental\.json'/);
|
|
|
|
assert.match(stderr, /'ofLife'/);
|
2022-01-06 11:07:52 +00:00
|
|
|
|
2022-07-29 08:42:55 +00:00
|
|
|
assert.notStrictEqual(code, 0);
|
|
|
|
});
|
|
|
|
});
|