Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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, {
Comment thread
geeksilva97 marked this conversation as resolved.
Outdated
__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
}
});
Comment thread
geeksilva97 marked this conversation as resolved.
Outdated
22 changes: 22 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,22 @@
// Flags: --no-warnings
'use strict';
const common = require('../common');
const assert = require('node:assert');
const { run } = require('node:test');
const fixtures = require('../common/fixtures');

const testFile = fixtures.path('test-runner', 'syntax-error-test.mjs');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As the original issue states "test:enqueue event has no file field", should we cover it with a test?

const stream = run({
files: [testFile],
isolation: 'none',
});

stream.on('test:enqueue', common.mustCall((data) => {
assert.ok(data.file, 'test:enqueue event should have file field');
assert.strictEqual(data.file, testFile);
}));

stream.on('test:fail', common.mustCall((data) => {
assert.ok(data.details.error);
assert.match(data.details.error.message, /SyntaxError/);
}));
Loading