diff --git a/test/cli/cli-main.js b/test/cli/cli-main.js index 030d3020f..be4079322 100644 --- a/test/cli/cli-main.js +++ b/test/cli/cli-main.js @@ -38,6 +38,7 @@ const fixtureCases = { 'uncaught error in "moduleDone" callback"': ['qunit', 'bad-callbacks/moduleDone-throw.js'], // FIXME: Details of testStart() error are swallowed 'uncaught error in "testStart" callback"': ['qunit', 'bad-callbacks/testStart-throw.js'], + 'rejection from callbacks': ['qunit', 'callbacks-rejected.js'], 'QUnit.hooks context': ['qunit', 'hooks-global-context.js'], diff --git a/test/cli/fixtures/callbacks-rejected.js b/test/cli/fixtures/callbacks-rejected.js new file mode 100644 index 000000000..821ebe5d8 --- /dev/null +++ b/test/cli/fixtures/callbacks-rejected.js @@ -0,0 +1,37 @@ +var caught = []; + +QUnit.on('error', function (e) { + caught.push(e.message); +}); + +QUnit.begin(function () { + return Promise.reject(new Error('begin')); +}); + +QUnit.moduleStart(function () { + return Promise.reject(new Error('moduleStart')); +}); + +QUnit.testStart(function () { + return Promise.reject(new Error('testStart')); +}); + +QUnit.done(function () { + setTimeout(function () { + console.log('Caught errors from ' + caught.join(', ')); + }, 100); +}); + +QUnit.done(function () { + return Promise.reject(new Error('done')); +}); + +QUnit.test('one', function (assert) { + assert.ok(true); +}); + +QUnit.module('example', function () { + QUnit.test('two', function (assert) { + assert.ok(true); + }); +}); diff --git a/test/cli/fixtures/expected/tap-outputs.js b/test/cli/fixtures/expected/tap-outputs.js index aca86598b..95fccd98f 100644 --- a/test/cli/fixtures/expected/tap-outputs.js +++ b/test/cli/fixtures/expected/tap-outputs.js @@ -303,6 +303,25 @@ Error: Process exited before tests finished running # stderr Error: Process exited before tests finished running +# exit code: 1`, + + 'qunit callbacks-rejected.js': +`TAP version 13 +not ok 1 global failure + --- + message: Error: begin + severity: failed + stack: | + Error: begin + at /qunit/test/cli/fixtures/callbacks-rejected.js:8:25 + at qunit.js + at internal + ... +Bail out! Error: begin + +# stderr +Error: Process exited before tests finished running + # exit code: 1`, 'qunit no-tests':