diff --git a/src/test.js b/src/test.js index cc494e359..5f8ebc105 100644 --- a/src/test.js +++ b/src/test.js @@ -752,7 +752,7 @@ Test.prototype = { `Test took longer than ${timeout}ms; test timed out.`, sourceFromStacktrace(2) ); - internalStart(test); + internalRecover(test); }; }; clearTimeout(config.timeout); diff --git a/test/cli/cli-main.js b/test/cli/cli-main.js index aeb2f37ae..030d3020f 100644 --- a/test/cli/cli-main.js +++ b/test/cli/cli-main.js @@ -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'], diff --git a/test/cli/fixtures/expected/tap-outputs.js b/test/cli/fixtures/expected/tap-outputs.js index 1abcd4b72..aca86598b 100644 --- a/test/cli/fixtures/expected/tap-outputs.js +++ b/test/cli/fixtures/expected/tap-outputs.js @@ -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': diff --git a/test/cli/fixtures/pending-async-after-timeout.js b/test/cli/fixtures/pending-async-after-timeout.js new file mode 100644 index 000000000..ed180dfcf --- /dev/null +++ b/test/cli/fixtures/pending-async-after-timeout.js @@ -0,0 +1,6 @@ +// Regression test for https://github.com/qunitjs/qunit/issues/1705 +QUnit.test( "example", async assert => { + assert.timeout( 10 ); + const done = assert.async(); + assert.true( true ); +} );