2020-01-20 06:40:26 +00:00
|
|
|
'use strict';
|
|
|
|
|
2022-07-29 08:42:55 +00:00
|
|
|
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');
|
|
|
|
|
2020-01-20 06:40:26 +00:00
|
|
|
|
2023-09-30 05:01:55 +00:00
|
|
|
// In a "type": "module" package scope, files with unknown extensions should throw;
|
|
|
|
// both when used as a main entry point and also when referenced via `import`.
|
2024-03-23 21:11:28 +00:00
|
|
|
describe('ESM: unknown specifiers', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
2022-07-29 08:42:55 +00:00
|
|
|
for (
|
|
|
|
const fixturePath of [
|
|
|
|
'/es-modules/package-type-module/extension.unknown',
|
|
|
|
'/es-modules/package-type-module/imports-unknownext.mjs',
|
|
|
|
]
|
|
|
|
) {
|
|
|
|
it('should throw', async () => {
|
|
|
|
const entry = fixtures.path(fixturePath);
|
|
|
|
const { code, signal, stderr, stdout } = await spawnPromisified(execPath, [entry]);
|
2020-01-20 06:40:26 +00:00
|
|
|
|
2022-07-29 08:42:55 +00:00
|
|
|
assert.strictEqual(code, 1);
|
|
|
|
assert.strictEqual(signal, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2023-09-29 06:18:44 +00:00
|
|
|
assert.match(stderr, /ERR_UNKNOWN_FILE_EXTENSION/);
|
2022-07-29 08:42:55 +00:00
|
|
|
});
|
|
|
|
}
|
2020-01-20 06:40:26 +00:00
|
|
|
});
|