Skip to content

Commit

Permalink
Core: Fix hanging assert.async() after assert.timeout()
Browse files Browse the repository at this point in the history
Follows-up 163c9bc (#1642),
which changed an internalRecover() to internalStart(), whereas
internalStart will (correctly) not resume if there are other pauses
still remaining.

Change this back to internalRecover().

Fixes #1705.
Closes #1739.
  • Loading branch information
Krinkle committed Feb 9, 2024
1 parent 0b776c1 commit 2e87e2a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ Test.prototype = {
`Test took longer than ${timeout}ms; test timed out.`,
sourceFromStacktrace(2)
);
internalStart(test);
internalRecover(test);
};
};
clearTimeout(config.timeout);
Expand Down
1 change: 1 addition & 0 deletions test/cli/cli-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const fixtureCases = {

'test with failing assertion': ['qunit', 'fail/failure.js'],
'test that hangs': ['qunit', 'hanging-test'],
'test with pending async after timeout': ['qunit', 'pending-async-after-timeout.js'],
'two tests with one timeout': ['qunit', 'timeout'],
'test with zero assertions': ['qunit', 'zero-assertions.js'],

Expand Down
19 changes: 19 additions & 0 deletions test/cli/fixtures/expected/tap-outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@ Extra reporters found among package dependencies: npm-reporter
Error: Process exited before tests finished running
Last test to run (hanging) has an async hold. Ensure all assert.async() callbacks are invoked and Promises resolve. You should also set a standard timeout via QUnit.config.testTimeout.
# exit code: 1`,

'qunit pending-async-after-timeout.js':
`TAP version 13
not ok 1 example
---
message: Test took longer than 10ms; test timed out.
severity: failed
actual : null
expected: undefined
stack: |
at internal
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1
# exit code: 1`,

'qunit unhandled-rejection.js':
Expand Down
7 changes: 7 additions & 0 deletions test/cli/fixtures/pending-async-after-timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Regression test for https://github.com/qunitjs/qunit/issues/1705
QUnit.test('example', async assert => {
assert.timeout(10);
// eslint-disable-next-line no-unused-vars
const done = assert.async();
assert.true(true);
});

0 comments on commit 2e87e2a

Please sign in to comment.