Skip to content

Commit c74541b

Browse files
.
1 parent 8dd3924 commit c74541b

File tree

5 files changed

+42
-58
lines changed

5 files changed

+42
-58
lines changed

test/es-module/test-cjs-esm-warn.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { mustCall } from '../common/index.mjs';
22
import * as fixtures from '../common/fixtures.mjs';
33
import assert from 'node:assert';
44
import path from 'node:path';
5+
import { execPath } from 'node:process';
56

67
import spawn from './helper.spawnAsPromised.mjs';
78

@@ -16,7 +17,7 @@ const pjson = path.resolve(
1617
fixtures.path('/es-modules/package-type-module/cjs.js')
1718
);
1819
const basename = 'cjs.js';
19-
spawn(process.execPath, [requiringCjsAsEsm])
20+
spawn(execPath, [requiringCjsAsEsm])
2021
.then(mustCall(({ code, signal, stderr }) => {
2122
assert.ok(
2223
stderr.replaceAll('\r', '').includes(
@@ -43,7 +44,7 @@ const pjson = path.resolve(
4344
fixtures.path('/es-modules/package-type-module/esm.js')
4445
);
4546
const basename = 'esm.js';
46-
spawn(process.execPath, [requiringEsm])
47+
spawn(execPath, [requiringEsm])
4748
.then(mustCall(({ code, signal, stderr }) => {
4849
assert.ok(
4950
stderr.replace(/\r/g, '').includes(

test/es-module/test-esm-cjs-builtins.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { mustCall } from '../common/index.mjs';
2+
import * as fixtures from '../common/fixtures.mjs';
3+
import assert from 'node:assert';
4+
import { execPath } from 'node:process';
5+
6+
import spawn from './helper.spawnAsPromised.mjs';
7+
8+
const entry = fixtures.path('/es-modules/builtin-imports-case.mjs');
9+
10+
spawn(execPath, [entry])
11+
.then(mustCall(({ code, signal, stdout }) => {
12+
assert.strictEqual(code, 0);
13+
assert.strictEqual(signal, null);
14+
assert.strictEqual(stdout, 'ok\n');
15+
}));

test/es-module/test-esm-cjs-exports.js

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { mustCall } from '../common/index.mjs';
2+
import * as fixtures from '../common/fixtures.mjs';
3+
import assert from 'node:assert';
4+
import { execPath } from 'node:process';
5+
6+
import spawn from './helper.spawnAsPromised.mjs';
7+
8+
9+
const validEntry = fixtures.path('/es-modules/cjs-exports.mjs');
10+
spawn(execPath, [validEntry])
11+
.then(mustCall(({ code, signal, stdout }) => {
12+
assert.strictEqual(code, 0);
13+
assert.strictEqual(signal, null);
14+
assert.strictEqual(stdout, 'ok\n');
15+
}));
16+
17+
const invalidEntry = fixtures.path('/es-modules/cjs-exports-invalid.mjs');
18+
spawn(execPath, [invalidEntry])
19+
.then(mustCall(({ code, signal, stderr }) => {
20+
assert.strictEqual(code, 1);
21+
assert.strictEqual(signal, null);
22+
assert.ok(stderr.includes('Warning: To load an ES module'));
23+
assert.ok(stderr.includes('Unexpected token \'export\''));
24+
}));

0 commit comments

Comments
 (0)