Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1865691

Browse filesBrowse files
geeksilva97aduh95
authored andcommitted
test_runner: set non-zero exit code when suite errors occur
PR-URL: #62282 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent ede52bc commit 1865691
Copy full SHA for 1865691

3 files changed

+21Lines changed: 21 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/utils.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ function countCompletedTest(test, harness = test.root.harness) {
384384
}
385385
if (test.reportedType === 'suite') {
386386
harness.counters.suites++;
387+
if (!test.passed) {
388+
harness.success = false;
389+
}
387390
return;
388391
}
389392
// Check SKIP and TODO tests first, as those should not be counted as
Collapse file
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
const { describe, it } = require('node:test');
3+
4+
describe('should fail', () => {
5+
throw new Error('error in describe');
6+
});
7+
8+
describe('should pass', () => {
9+
it('ok', () => {});
10+
});
Collapse file

‎test/parallel/test-runner-exit-code.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-exit-code.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ if (process.argv[2] === 'child') {
7070
assert.strictEqual(child.status, 1);
7171
assert.strictEqual(child.signal, null);
7272

73+
// An error thrown inside describe() should cause a non-zero exit code.
74+
child = spawnSync(process.execPath, [
75+
'--test',
76+
fixtures.path('test-runner', 'describe_error.js'),
77+
]);
78+
assert.strictEqual(child.status, 1);
79+
assert.strictEqual(child.signal, null);
80+
7381
// With process isolation (default), the test name shown is the file path
7482
// because the parent runner only knows about file-level tests
7583
const neverEndingSync = fixtures.path('test-runner', 'never_ending_sync.js');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.