You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This script produces four errors at the level of the top suite:
const Jasmine = require('jasmine');
const JasmineConsoleReporter = require('jasmine-console-reporter');
const jasmine = new Jasmine();
const reporter = new JasmineConsoleReporter();
jasmine.clearReporters();
jasmine.addReporter(reporter);
beforeAll(function() {
throw new Error('a beforeAll exception');
});
it('causes errors after the spec is done', async function() {
Promise.reject(new Error('an unhandled rejection "in" a spec'));
setTimeout(function() {
throw new Error('an async failure after the spec finished');
});
});
afterAll(function(done) {
// Ensure that the late failures above happen before the suite finishes
setTimeout(done, 1000);
throw new Error('an afterAll exception');
});
jasmine.execute();
When I run it, jasmine-console-reporter reports an overall result of "failed" but doesn't show any particulars:
$ node --version
v16.0.0
$ node test.js
Executing 1 defined specs...
Running in random order... (seed: 24753)
Test Suites & Specs:
✔ causes errors after the spec is done (1ms)
>> Done!
Summary:
❌ Failed
Suites: 0 of 0
Specs: 1 of 1
Expects: 0 (none executed)
Finished in 0.006 seconds
If I comment out the jasmine.clearReporters and jasmine.addReporter calls, Jasmine's default console reporter displays the failures:
$ node test.js
Randomized with seed 16079
Started
.
Suite error: undefined
Message:
Error: a beforeAll exception
Stack:
Error: a beforeAll exception
at UserContext.<anonymous> (/path/to/test.js:12:8)
at <Jasmine>
at processImmediate (node:internal/timers:464:21)
Message:
Unhandled promise rejection: Error: an unhandled rejection "in" a spec
Stack:
Error: an unhandled rejection "in" a spec
at UserContext.<anonymous> (/path/to/test.js:16:17)
at <Jasmine>
at processImmediate (node:internal/timers:464:21)
Message:
Uncaught exception: Error: an async failure after the spec finished
Stack:
Error: an async failure after the spec finished
at Timeout._onTimeout (/path/to/test.js:18:9)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
Message:
Error: an afterAll exception
Stack:
Error: an afterAll exception
at UserContext.<anonymous> (/path/to/test.js:25:8)
at <Jasmine>
at processImmediate (node:internal/timers:464:21)
1 spec, 0 failures
Finished in 0.006 seconds
Randomized with seed 16079 (jasmine --random=true --seed=16079)
Likewise, jasmine-console-reporter displays them if I wrap everything in a describe:
$ node test.js
Executing 1 defined specs...
Running in random order... (seed: 41097)
Test Suites & Specs:
1. a suite
✔ causes errors after the spec is done (1ms)
>> Done!
Summary:
❌ Failed
Suites: 1 of 1
Specs: 1 of 1
Expects: 0 (none executed)
Finished in 0.008 seconds
>> An error was thrown in an afterAll
Error: a beforeAll exception
at UserContext.<anonymous> /path/to/test.js:11:8
at <Jasmine>
at processImmediate node:internal/timers:464:21
>> An error was thrown in an afterAll
Unhandled promise rejection: Error: an unhandled rejection "in" a spec
at UserContext.<anonymous> /path/to/test.js:15:17
at <Jasmine>
at processImmediate node:internal/timers:464:21
>> An error was thrown in an afterAll
Uncaught exception: Error: an async failure after the spec finished
at Timeout._onTimeout /path/to/test.js:17:9
at listOnTimeout node:internal/timers:557:17
at processTimers node:internal/timers:500:7
>> An error was thrown in an afterAll
Error: an afterAll exception
at UserContext.<anonymous> /path/to/test.js:24:8
at <Jasmine>
at processImmediate node:internal/timers:464:21
Top suite failures are relatively common even when all specs are wrapped in a describe. They can happen when there's a top-level beforeAll or afterAll. Unhandled exceptions and promise rejections that happen after a spec signals completion are also commonly routed to the top suite, especially in small test suites, although that's highly sensitive to timing.
The text was updated successfully, but these errors were encountered:
This script produces four errors at the level of the top suite:
When I run it, jasmine-console-reporter reports an overall result of "failed" but doesn't show any particulars:
If I comment out the
jasmine.clearReporters
andjasmine.addReporter
calls, Jasmine's default console reporter displays the failures:Likewise, jasmine-console-reporter displays them if I wrap everything in a
describe
:Top suite failures are relatively common even when all specs are wrapped in a
describe
. They can happen when there's a top-levelbeforeAll
orafterAll
. Unhandled exceptions and promise rejections that happen after a spec signals completion are also commonly routed to the top suite, especially in small test suites, although that's highly sensitive to timing.The text was updated successfully, but these errors were encountered: