Skip to content

Commit 98a519b

Browse files
committed
test: use spawnSyncAndAssert in extensionless ESM test
1 parent 06a7ad2 commit 98a519b

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

test/es-module/test-extensionless-esm-type-commonjs.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict';
22

3-
const assert = require('node:assert/strict');
43
const fs = require('node:fs');
54
const path = require('node:path');
6-
const { spawnSync } = require('node:child_process');
7-
5+
const { spawnSyncAndAssert } = require('../common/child_process');
86
const tmpdir = require('../common/tmpdir');
97

108
tmpdir.refresh();
@@ -32,16 +30,11 @@ fs.writeFileSync(
3230
);
3331
fs.chmodSync(scriptPath, 0o755);
3432

35-
const r = spawnSync(process.execPath, ['./script'], {
33+
spawnSyncAndAssert(process.execPath, ['./script'], {
3634
cwd: dir,
37-
encoding: 'utf8'
35+
encoding: 'utf8',
36+
}, {
37+
status: 1,
38+
stderr: /.+/,
39+
trim: true,
3840
});
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)