11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst { checkoutEOL, spawnPromisified } = require('../common'); 41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures.js'); 51cb0ef41Sopenharmony_ciconst assert = require('node:assert'); 61cb0ef41Sopenharmony_ciconst { execPath } = require('node:process'); 71cb0ef41Sopenharmony_ciconst { describe, it } = require('node:test'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cidescribe('ESM: Package.json', { concurrency: true }, () => { 111cb0ef41Sopenharmony_ci it('should throw on invalid pson', async () => { 121cb0ef41Sopenharmony_ci const entry = fixtures.path('/es-modules/import-invalid-pjson.mjs'); 131cb0ef41Sopenharmony_ci const invalidJson = fixtures.path('/node_modules/invalid-pjson/package.json'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci const { code, signal, stderr } = await spawnPromisified(execPath, [entry]); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci assert.ok( 181cb0ef41Sopenharmony_ci stderr.includes( 191cb0ef41Sopenharmony_ci `[ERR_INVALID_PACKAGE_CONFIG]: Invalid package config ${invalidJson} ` + 201cb0ef41Sopenharmony_ci `while importing "invalid-pjson" from ${entry}. ` + 211cb0ef41Sopenharmony_ci `Unexpected token } in JSON at position ${12 + checkoutEOL.length * 2}` 221cb0ef41Sopenharmony_ci ), 231cb0ef41Sopenharmony_ci stderr 241cb0ef41Sopenharmony_ci ); 251cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 261cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 271cb0ef41Sopenharmony_ci }); 281cb0ef41Sopenharmony_ci}); 29