diff --git a/src/core/processing-queue.js b/src/core/processing-queue.js index 0967d3a27..17204c7bd 100644 --- a/src/core/processing-queue.js +++ b/src/core/processing-queue.js @@ -1,6 +1,6 @@ import config from "./config"; -import onUncaughtException from "./on-uncaught-exception"; import { + extend, generateHash, now } from "./utilities"; @@ -9,6 +9,9 @@ import { } from "./logging"; import Promise from "../promise"; +import { + test +} from "../test"; import { globalSuite } from "../core"; @@ -158,16 +161,10 @@ function unitSamplerGenerator( seed ) { * items. It handles emitting the final run events. */ function done() { - const storage = config.storage; - - const runtime = now() - config.started; - const passed = config.stats.all - config.stats.bad; - - ProcessingQueue.finished = true; // We have reached the end of the processing queue and are about to emit the // "runEnd" event after which reporters typically stop listening and exit - // the process. First, check if we need to emit one final error. + // the process. First, check if we need to emit one final test. if ( config.stats.testCount === 0 && config.failOnZeroTests === true ) { let error; if ( config.filter && config.filter.length ) { @@ -182,9 +179,28 @@ function done() { error = new Error( "No tests were run." ); } - onUncaughtException( error ); + test( "global failure", extend( function( assert ) { + assert.pushResult( { + result: false, + message: error.message, + source: error.stack + } ); + }, { validTest: true } ) ); + + // We do need to call `advance()` in order to resume the processing queue. + // Once this new test is finished processing, we'll reach `done` again, and + // that time the above condition will evaluate to false. + advance(); + return; } + const storage = config.storage; + + const runtime = now() - config.started; + const passed = config.stats.all - config.stats.bad; + + ProcessingQueue.finished = true; + emit( "runEnd", globalSuite.end( true ) ); runLoggingCallbacks( "done", { passed, diff --git a/src/html-reporter/html.js b/src/html-reporter/html.js index 60437a638..e6784d7ca 100644 --- a/src/html-reporter/html.js +++ b/src/html-reporter/html.js @@ -1,5 +1,4 @@ import QUnit from "../core"; -import Logger from "../logger"; import { extend, errorString } from "../core/utilities"; import { window, document, navigator, console } from "../globals"; import "./urlparams"; @@ -1035,8 +1034,6 @@ export function escapeText( s ) { if ( !testItem ) { // HTML Reporter is probably disabled or not yet initialized. - Logger.warn( "global failure" ); - Logger.warn( error ); return; } diff --git a/src/test.js b/src/test.js index 02424bae6..574d85481 100644 --- a/src/test.js +++ b/src/test.js @@ -76,6 +76,13 @@ export default function Test( settings ) { ++Test.count; this.errorForStack = new Error(); + if ( this.callback && this.callback.validTest ) { + + // Omit the test-level trace for the internal "No tests" test failure, + // There is already an assertion-level trace, and that's noisy enough + // as it is. + this.errorForStack.stack = undefined; + } this.testReport = new TestReport( this.testName, this.module.suiteReport, { todo: this.todo, skip: this.skip, diff --git a/test/cli/fixtures/expected/tap-outputs.js b/test/cli/fixtures/expected/tap-outputs.js index 78d927d24..055245345 100644 --- a/test/cli/fixtures/expected/tap-outputs.js +++ b/test/cli/fixtures/expected/tap-outputs.js @@ -143,8 +143,10 @@ not ok 2 Unhandled Rejections > test passes just fine, but has a rejected promis `TAP version 13 not ok 1 global failure --- - message: Error: No tests were run. + message: No tests were run. severity: failed + actual : undefined + expected: undefined stack: | Error: No tests were run. at done (/qunit/qunit/qunit.js) @@ -153,7 +155,6 @@ not ok 1 global failure at unblockAndAdvanceQueue (/qunit/qunit/qunit.js) at internal ... -Bail out! Error: No tests were run. 1..1 # pass 0 # skip 0 @@ -236,8 +237,10 @@ ok 1 Zero assertions > has a test `TAP version 13 not ok 1 global failure --- - message: "Error: No tests matched the filter \\"no matches\\"." + message: "No tests matched the filter \\"no matches\\"." severity: failed + actual : undefined + expected: undefined stack: | Error: No tests matched the filter "no matches". at done (/qunit/qunit/qunit.js) @@ -246,7 +249,6 @@ not ok 1 global failure at unblockAndAdvanceQueue (/qunit/qunit/qunit.js) at internal ... -Bail out! Error: No tests matched the filter "no matches". 1..1 # pass 0 # skip 0