Skip to content

Commit

Permalink
Merge pull request #84 from ybian/null_stack
Browse files Browse the repository at this point in the history
Fix #83 - default console reporter hangs sometimes
  • Loading branch information
Gregg Van Hove authored Sep 28, 2016
2 parents df43829 + 6de5013 commit 1b60f4a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/reporters/console_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ function ConsoleReporter() {
}

function defaultStackFilter(stack) {
if (!stack) {
return '';
}

var filteredStack = stack.split('\n').filter(function(stackLine) {
return stackLine.indexOf(jasmineCorePath) === -1;
}).join('\n');
Expand Down
30 changes: 30 additions & 0 deletions spec/reporters/console_reporter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,36 @@ describe("ConsoleReporter", function() {
expect(this.out.getOutput()).not.toMatch(jasmineCorePath);
});

it("reports a summary when done in case that stack is somehow undefined", function() {
var reporter = new ConsoleReporter({
print: this.out.print,
jasmineCorePath: jasmineCorePath
});

reporter.jasmineStarted();
reporter.specDone({status: "passed"});
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec",
failedExpectations: [
{
passed: false,
message: "Expected true to be false.",
expected: false,
actual: true,
stack: undefined
}
]
});

this.out.clear();

reporter.jasmineDone();

expect(this.out.getOutput()).toMatch(/true to be false/);
});

it("reports a summary when done that includes custom filtered stack traces for a failing suite", function() {
var stackLine = 'custom line of stack';
var customStackFilter = function(stack) {
Expand Down

0 comments on commit 1b60f4a

Please sign in to comment.