Skip to content

Commit 06a7ad2

Browse files
committed
test: remove unnecessary node:test wrapper from single test
1 parent 682ec4f commit 06a7ad2

1 file changed

Lines changed: 37 additions & 40 deletions

File tree

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
11
'use strict';
22

3-
const test = require('node:test');
43
const assert = require('node:assert/strict');
54
const fs = require('node:fs');
65
const path = require('node:path');
76
const { spawnSync } = require('node:child_process');
87

98
const tmpdir = require('../common/tmpdir');
109

11-
test('extensionless entry point with ESM syntax under type=commonjs should not silently exit 0', () => {
12-
tmpdir.refresh();
13-
14-
const dir = tmpdir.resolve('extensionless-esm-commonjs');
15-
fs.mkdirSync(dir, { recursive: true });
16-
17-
// package.json with type: commonjs
18-
fs.writeFileSync(
19-
path.join(dir, 'package.json'),
20-
'{\n "type": "commonjs"\n}\n',
21-
'utf8'
22-
);
23-
24-
// Extensionless executable with shebang + ESM syntax.
25-
// NOTE: Execute via process.execPath to avoid PATH/env differences.
26-
const scriptPath = path.join(dir, 'script'); // no extension
27-
fs.writeFileSync(
28-
scriptPath,
29-
'#!/usr/bin/env node\n' +
30-
"console.log('script STARTED')\n" +
31-
"import { version } from 'node:process'\n" +
32-
'console.log(version)\n',
33-
'utf8'
34-
);
35-
fs.chmodSync(scriptPath, 0o755);
36-
37-
const r = spawnSync(process.execPath, ['./script'], {
38-
cwd: dir,
39-
encoding: 'utf8'
40-
});
41-
42-
assert.ifError(r.error);
43-
44-
assert.notEqual(
45-
r.status,
46-
0,
47-
`unexpected exit code 0; stdout=${JSON.stringify(r.stdout)} stderr=${JSON.stringify(r.stderr)}`
48-
);
49-
assert.ok(r.stderr && r.stderr.length > 0, 'expected stderr to contain an error message');
10+
tmpdir.refresh();
11+
12+
const dir = tmpdir.resolve('extensionless-esm-commonjs');
13+
fs.mkdirSync(dir, { recursive: true });
14+
15+
// package.json with type: commonjs
16+
fs.writeFileSync(
17+
path.join(dir, 'package.json'),
18+
'{\n "type": "commonjs"\n}\n',
19+
'utf8'
20+
);
21+
22+
// Extensionless executable with shebang + ESM syntax.
23+
// NOTE: Execute via process.execPath to avoid PATH/env differences.
24+
const scriptPath = path.join(dir, 'script'); // no extension
25+
fs.writeFileSync(
26+
scriptPath,
27+
'#!/usr/bin/env node\n' +
28+
"console.log('script STARTED')\n" +
29+
"import { version } from 'node:process'\n" +
30+
'console.log(version)\n',
31+
'utf8'
32+
);
33+
fs.chmodSync(scriptPath, 0o755);
34+
35+
const r = spawnSync(process.execPath, ['./script'], {
36+
cwd: dir,
37+
encoding: 'utf8'
5038
});
39+
40+
assert.ifError(r.error);
41+
42+
assert.notEqual(
43+
r.status,
44+
0,
45+
`unexpected exit code 0; stdout=${JSON.stringify(r.stdout)} stderr=${JSON.stringify(r.stderr)}`
46+
);
47+
assert.ok(r.stderr && r.stderr.length > 0, 'expected stderr to contain an error message');

0 commit comments

Comments
 (0)