jasmine-reporters icon indicating copy to clipboard operation
jasmine-reporters copied to clipboard

stack can be undefined on uncaught exceptions causing TerminalReporter to throw

Open catdad opened this issue 2 years ago • 0 comments

Sometimes (it is unclear to me when) uncaught exceptions that fail tests will not include a stack property. When this happens, the TerminalReporter throws an error. Worse, any reporters registered after the TerminalReporter are not notified of this failure, which is pretty bad.

My tests that repro this issue

describe('my tests', function() {
    it('throws async error', function () {
        setTimeout(function () {
            throw new Error('I am the error');
        }, 5);
    });

    it('just waits a bunch', function(done) {
        setTimeout(function () {
            done();
        }, 100);
    });
});

This throws an error here: https://github.com/larrymyers/jasmine-reporters/blob/491efaaafe97b7b02ab0788aeb41481cf345cd8e/src/terminal_reporter.js#L185

This should be an easy fix...

if (self.showStack && spec.failedExpectations[i].stack){

catdad avatar Nov 15 '22 20:11 catdad