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
3 changes: 3 additions & 0 deletions lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ function countCompletedTest(test, harness = test.root.harness) {
}
if (test.reportedType === 'suite') {
harness.counters.suites++;
if (!test.passed) {
harness.success = false;
}
return;
}
// Check SKIP and TODO tests first, as those should not be counted as
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/test-runner/describe_error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';
const { describe, it } = require('node:test');

describe('should fail', () => {
throw new Error('error in describe');
});

describe('should pass', () => {
it('ok', () => {});
});
8 changes: 8 additions & 0 deletions test/parallel/test-runner-exit-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ if (process.argv[2] === 'child') {
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);

// An error thrown inside describe() should cause a non-zero exit code.
child = spawnSync(process.execPath, [
'--test',
fixtures.path('test-runner', 'describe_error.js'),
]);
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);

// With process isolation (default), the test name shown is the file path
// because the parent runner only knows about file-level tests
const neverEndingSync = fixtures.path('test-runner', 'never_ending_sync.js');
Expand Down
Loading