Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: abort unfinished tests on async error #51996

Merged
merged 1 commit into from
Mar 9, 2024
Merged
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
2 changes: 1 addition & 1 deletion lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function createProcessEventHandler(eventName, rootTest) {
}

test.fail(new ERR_TEST_FAILURE(err, eventName));
test.postRun();
test.abortController.abort();
};
}

Expand Down
4 changes: 1 addition & 3 deletions test/fixtures/test-runner/output/describe_it.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,9 @@ not ok 50 - custom inspect symbol that throws fail
*
*
*
async Promise.all (index 0)
*
*
*
async Promise.all (index 0)
...
1..2
not ok 51 - subtest sync throw fails
Expand Down Expand Up @@ -628,7 +627,6 @@ not ok 54 - timeouts
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
...
1..2
not ok 55 - successful thenable
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/test-runner/output/junit_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
*
*
*
*
*
}
</failure>
</testcase>
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/test-runner/output/output.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ not ok 51 - custom inspect symbol that throws fail
*
*
*
*
*
...
1..2
not ok 52 - subtest sync throw fails
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/test-runner/output/output_cli.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ not ok 51 - custom inspect symbol that throws fail
*
*
*
*
*
...
1..2
not ok 52 - subtest sync throw fails
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/test-runner/output/spec_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@
*
*
*
*
*

subtest sync throw fails (*ms)

Expand Down Expand Up @@ -515,8 +513,6 @@
*
*
*
*
*

*
timed out async test (*ms)
Expand Down
4 changes: 0 additions & 4 deletions test/fixtures/test-runner/output/spec_reporter_cli.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@
*
*
*
*
*

subtest sync throw fails (*ms)

Expand Down Expand Up @@ -515,8 +513,6 @@
*
*
*
*
*

*
timed out async test (*ms)
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/test-runner/output/unfinished-suite-async-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
const { describe, it } = require('node:test');

describe('unfinished suite with asynchronous error', () => {
it('uses callback', (t, done) => {
setImmediate(() => {
throw new Error('callback test does not complete');
});
});

it('should pass 1');
});

it('should pass 2');
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
TAP version 13
# Subtest: unfinished suite with asynchronous error
# Subtest: uses callback
not ok 1 - uses callback
---
duration_ms: *
location: '/test/fixtures/test-runner/output/unfinished-suite-async-error.js:(LINE):3'
failureType: 'uncaughtException'
error: 'callback test does not complete'
code: 'ERR_TEST_FAILURE'
stack: |-
*
*
...
# Subtest: should pass 1
ok 2 - should pass 1
---
duration_ms: *
...
1..2
not ok 1 - unfinished suite with asynchronous error
---
duration_ms: *
type: 'suite'
location: '/test/fixtures/test-runner/output/unfinished-suite-async-error.js:(LINE):1'
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: should pass 2
ok 2 - should pass 2
---
duration_ms: *
...
1..2
# tests 3
# suites 1
# pass 2
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
1 change: 1 addition & 0 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const tests = [
{ name: 'test-runner/output/output_cli.js' },
{ name: 'test-runner/output/name_pattern.js' },
{ name: 'test-runner/output/name_pattern_with_only.js' },
{ name: 'test-runner/output/unfinished-suite-async-error.js' },
{ name: 'test-runner/output/unresolved_promise.js' },
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
{ name: 'test-runner/output/arbitrary-output.js' },
Expand Down
Loading