Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,10 @@ function run(options = kEmptyObject) {
);
if (topLevelTestCount === root.subtests.length) {
// This file had no tests in it. Add the placeholder test.
const subtest = root.createSubtest(Test, testFile);
const subtest = root.createSubtest(Test, testFile, { __proto__: null }, undefined, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const subtest = root.createSubtest(Test, testFile, { __proto__: null }, undefined, {
const subtest = root.createSubtest(Test, testFile, kEmptyObject, undefined, {

__proto__: null,
loc: [1, 1, resolve(testFile)],
});
if (threw) {
subtest.fail(importError);
}
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/test-runner/syntax-error-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test } from 'node:test';

test('a test!', () => {
if true {
// syntax error
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
});
});

19 changes: 19 additions & 0 deletions test/parallel/test-runner-enqueue-file-syntax-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
require('../common');
const assert = require('node:assert');
const { spawnSync } = require('node:child_process');
const fixtures = require('../common/fixtures');

const testFile = fixtures.path('test-runner', 'syntax-error-test.mjs');
const child = spawnSync(process.execPath, [
'--no-warnings',
'--test',
'--test-reporter=tap',
'--test-isolation=none',
testFile,
], { encoding: 'utf8' });

assert.match(child.stdout, new RegExp(`# Subtest: ${testFile}`));
assert.match(child.stdout, /location:.*syntax-error-test\.mjs/);
assert.match(child.stdout, /SyntaxError/);
assert.strictEqual(child.status, 1);
Loading