mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
45f0dd0192
Fixes: https://github.com/nodejs/node/issues/50753 PR-URL: https://github.com/nodejs/node/pull/51097 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
29 lines
1004 B
JavaScript
29 lines
1004 B
JavaScript
'use strict';
|
|
|
|
const { spawnPromisified } = require('../common');
|
|
const fixtures = require('../common/fixtures.js');
|
|
const assert = require('node:assert');
|
|
const path = require('node:path');
|
|
const { execPath } = require('node:process');
|
|
const { describe, it } = require('node:test');
|
|
|
|
|
|
describe('ESM: Package.json', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
|
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 ${path.toNamespacedPath(invalidJson)} while importing "invalid-pjson" from ${entry}.`
|
|
),
|
|
stderr
|
|
);
|
|
assert.strictEqual(code, 1);
|
|
assert.strictEqual(signal, null);
|
|
});
|
|
});
|