1'use strict'; 2 3const { spawnPromisified } = require('../common'); 4const fixtures = require('../common/fixtures.js'); 5const assert = require('node:assert'); 6const { execPath } = require('node:process'); 7const { describe, it } = require('node:test'); 8 9 10// In a "type": "module" package scope, files with unknown extensions should throw; 11// both when used as a main entry point and also when referenced via `import`. 12describe('ESM: unknown specifiers', { concurrency: true }, () => { 13 for ( 14 const fixturePath of [ 15 '/es-modules/package-type-module/extension.unknown', 16 '/es-modules/package-type-module/imports-unknownext.mjs', 17 ] 18 ) { 19 it('should throw', async () => { 20 const entry = fixtures.path(fixturePath); 21 const { code, signal, stderr, stdout } = await spawnPromisified(execPath, [entry]); 22 23 assert.strictEqual(code, 1); 24 assert.strictEqual(signal, null); 25 assert.strictEqual(stdout, ''); 26 assert.match(stderr, /ERR_UNKNOWN_FILE_EXTENSION/); 27 }); 28 } 29}); 30