2020-05-04 09:50:42 +00:00
|
|
|
'use strict';
|
|
|
|
|
2023-10-25 21:51:27 +00:00
|
|
|
const { spawnPromisified } = require('../common');
|
2022-07-29 08:42:55 +00:00
|
|
|
const fixtures = require('../common/fixtures.js');
|
|
|
|
const assert = require('node:assert');
|
2024-04-08 14:37:46 +00:00
|
|
|
const path = require('node:path');
|
2022-07-29 08:42:55 +00:00
|
|
|
const { execPath } = require('node:process');
|
|
|
|
const { describe, it } = require('node:test');
|
2020-05-04 09:50:42 +00:00
|
|
|
|
|
|
|
|
2024-03-23 21:11:28 +00:00
|
|
|
describe('ESM: Package.json', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
2022-07-29 08:42:55 +00:00
|
|
|
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]);
|
|
|
|
|
2023-10-25 21:51:27 +00:00
|
|
|
assert.ok(stderr.includes('code: \'ERR_INVALID_PACKAGE_CONFIG\''), stderr);
|
2022-07-29 08:42:55 +00:00
|
|
|
assert.ok(
|
|
|
|
stderr.includes(
|
2024-04-08 14:37:46 +00:00
|
|
|
`Invalid package config ${path.toNamespacedPath(invalidJson)} while importing "invalid-pjson" from ${entry}.`
|
2022-07-29 08:42:55 +00:00
|
|
|
),
|
|
|
|
stderr
|
|
|
|
);
|
|
|
|
assert.strictEqual(code, 1);
|
|
|
|
assert.strictEqual(signal, null);
|
|
|
|
});
|
2020-05-04 09:50:42 +00:00
|
|
|
});
|