forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-esm-invalid-pjson.js
27 lines (22 loc) · 946 Bytes
/
test-esm-invalid-pjson.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'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: !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 ${invalidJson} while importing "invalid-pjson" from ${entry}.`
),
stderr
);
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);
});
});