Skip to content

Commit 1e6e3dd

Browse files
committed
test: improve test
1 parent ffdc923 commit 1e6e3dd

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const assert = require('node:assert');
4-
const { spawnSync } = require('node:child_process');
54
const fixtures = require('../common/fixtures');
5+
const { run } = require('node:test');
66

77
const testFile = fixtures.path('test-runner', 'syntax-error-test.mjs');
8-
const child = spawnSync(process.execPath, [
9-
'--no-warnings',
10-
'--test',
11-
'--test-reporter=tap',
12-
'--test-isolation=none',
13-
testFile,
14-
], { encoding: 'utf8' });
8+
const testRun = run({
9+
files: [testFile],
10+
isolation: 'none'
11+
});
1512

16-
assert.match(child.stdout, /error:.*"Unexpected token 'true'"\n/);
17-
assert.match(child.stdout, /SyntaxError/);
18-
assert.strictEqual(child.status, 1);
13+
testRun.on('test:enqueue', common.mustCall((test) => {
14+
assert.strictEqual(test.file, testFile);
15+
}));
16+
17+
testRun.on('test:fail', common.mustCall((test) => {
18+
assert.match(test.details.error.toString(), /SyntaxError: Unexpected token 'true'/);
19+
}));

0 commit comments

Comments
 (0)