mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Co-authored-by: Daniel Lemire <daniel@lemire.me> PR-URL: https://github.com/nodejs/node/pull/50322 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
28 lines
924 B
JavaScript
28 lines
924 B
JavaScript
'use strict';
|
|
|
|
const { spawnPromisified } = require('../common');
|
|
const fixtures = require('../common/fixtures.js');
|
|
const assert = require('node:assert');
|
|
const { execPath } = require('node:process');
|
|
const { describe, it } = require('node:test');
|
|
|
|
|
|
describe('ESM: Package.json', { concurrency: true }, () => {
|
|
it('should throw on invalid pson', async () => {
|
|
const entry = fixtures.path('/es-modules/import-invalid-pjson.mjs');
|
|
const invalidJson = fixtures.path('/node_modules/invalid-pjson/package.json');
|
|
|
|
const { code, signal, stderr } = await spawnPromisified(execPath, [entry]);
|
|
|
|
assert.ok(stderr.includes('code: \'ERR_INVALID_PACKAGE_CONFIG\''), stderr);
|
|
assert.ok(
|
|
stderr.includes(
|
|
`Invalid package config ${invalidJson} while importing "invalid-pjson" from ${entry}.`
|
|
),
|
|
stderr
|
|
);
|
|
assert.strictEqual(code, 1);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
});
|