Skip to content

Commit 9d9618d

Browse files
committed
Test: add fixture for rejected "begin", "moduleStart", "done" callbacks
I'm adding this as a CLI fixture instead of an HTML fixture because we don't currently have a good way of expecting a failure in an HTML test run. I've confirmed that the "hanging" appearance described in #1391 is equivalent to the "Process exited before tests finished running" message reported. Once we switch to capturing TAP by default, this will make the HTML tests much easier to verify no matter whether the pass/fail outcome. Ref #1391.
1 parent e614a2f commit 9d9618d

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

test/cli/cli-main.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const fixtureCases = {
3838
'uncaught error in "moduleDone" callback"': ['qunit', 'bad-callbacks/moduleDone-throw.js'],
3939
// FIXME: Details of testStart() error are swallowed
4040
'uncaught error in "testStart" callback"': ['qunit', 'bad-callbacks/testStart-throw.js'],
41+
'rejection from callbacks': ['qunit', 'callbacks-rejected.js'],
4142

4243
'QUnit.hooks context': ['qunit', 'hooks-global-context.js'],
4344

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var caught = [];
2+
3+
QUnit.on('error', function (e) {
4+
caught.push(e.message);
5+
});
6+
7+
QUnit.begin(function () {
8+
return Promise.reject(new Error('begin'));
9+
});
10+
11+
QUnit.moduleStart(function () {
12+
return Promise.reject(new Error('moduleStart'));
13+
});
14+
15+
QUnit.testStart(function () {
16+
return Promise.reject(new Error('testStart'));
17+
});
18+
19+
QUnit.done(function () {
20+
setTimeout(function () {
21+
console.log('Caught errors from ' + caught.join(', '));
22+
}, 100);
23+
});
24+
25+
QUnit.done(function () {
26+
return Promise.reject(new Error('done'));
27+
});
28+
29+
QUnit.test('one', function (assert) {
30+
assert.ok(true);
31+
});
32+
33+
QUnit.module('example', function () {
34+
QUnit.test('two', function (assert) {
35+
assert.ok(true);
36+
});
37+
});

test/cli/fixtures/expected/tap-outputs.js

+19
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,25 @@ Error: Process exited before tests finished running
303303
# stderr
304304
Error: Process exited before tests finished running
305305
306+
# exit code: 1`,
307+
308+
'qunit callbacks-rejected.js':
309+
`TAP version 13
310+
not ok 1 global failure
311+
---
312+
message: Error: begin
313+
severity: failed
314+
stack: |
315+
Error: begin
316+
at /qunit/test/cli/fixtures/callbacks-rejected.js:8:25
317+
at qunit.js
318+
at internal
319+
...
320+
Bail out! Error: begin
321+
322+
# stderr
323+
Error: Process exited before tests finished running
324+
306325
# exit code: 1`,
307326

308327
'qunit no-tests':

0 commit comments

Comments
 (0)