Skip to content

Commit e3b1233

Browse files
committed
update tests
1 parent 6398be7 commit e3b1233

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const fixtures = require('../common/fixtures');
5+
const { spawn } = require('child_process');
6+
const assert = require('assert');
7+
8+
// In a "type": "module" package scope, files with no extensions should
9+
// not throw; both when used as a main entry point and also when
10+
// referenced via `import`.
11+
12+
[
13+
'/es-modules/package-type-module/noext-esm',
14+
'/es-modules/package-type-module/imports-noext.mjs',
15+
].forEach((fixturePath) => {
16+
const entry = fixtures.path(fixturePath);
17+
const child = spawn(process.execPath, [entry]);
18+
let stdout = '';
19+
let stderr = '';
20+
child.stderr.setEncoding('utf8');
21+
child.stdout.setEncoding('utf8');
22+
child.stdout.on('data', (data) => {
23+
stdout += data;
24+
});
25+
child.stderr.on('data', (data) => {
26+
stderr += data;
27+
});
28+
child.on('close', common.mustCall((code, signal) => {
29+
assert.strictEqual(code, 0);
30+
assert.strictEqual(signal, null);
31+
assert.strictEqual(stdout, 'executed\n');
32+
assert.ok(stderr.indexOf('ERR_UNKNOWN_FILE_EXTENSION') === -1);
33+
}));
34+
});

test/es-module/test-esm-unknown-or-no-extension.js renamed to test/es-module/test-esm-unknown-extension.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ const fixtures = require('../common/fixtures');
55
const { spawn } = require('child_process');
66
const assert = require('assert');
77

8-
// In a "type": "module" package scope, files with unknown extensions or no
9-
// extensions should throw; both when used as a main entry point and also when
8+
// In a "type": "module" package scope, files with unknown extensions
9+
// should throw; both when used as a main entry point and also when
1010
// referenced via `import`.
1111

1212
[
13-
'/es-modules/package-type-module/noext-esm',
14-
'/es-modules/package-type-module/imports-noext.mjs',
1513
'/es-modules/package-type-module/extension.unknown',
1614
'/es-modules/package-type-module/imports-unknownext.mjs',
1715
].forEach((fixturePath) => {

0 commit comments

Comments
 (0)