Skip to content

Commit

Permalink
Display traces when present
Browse files Browse the repository at this point in the history
  • Loading branch information
sgravrock committed Sep 22, 2021
1 parent da9decc commit 18098bf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/reporters/console_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ function ConsoleReporter() {
print(failedSpecNumber + ') ');
print(result.fullName);
printFailedExpectations(result);

if (result.trace) {
printNewline();
print(indent('Trace:', 2));
printNewline();

for (const entry of result.trace) {
print(indent(`${entry.timestamp}ms: ${entry.message}`, 4));
printNewline();
}
}
}

function suiteFailureDetails(result) {
Expand Down
24 changes: 24 additions & 0 deletions spec/reporters/console_reporter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,30 @@ describe("ConsoleReporter", function() {
expect(this.out.getOutput()).not.toContain("Spec has no expectations");
});

it('reports a summary with trace info for a failed spec with trace', function() {
const reporter = new ConsoleReporter();
reporter.setOptions({
print: this.out.print,
jasmineCorePath: jasmineCorePath
});

reporter.jasmineStarted();
reporter.specDone({
status: "failed",
description: "with a failing spec",
fullName: "A suite with a failing spec that has a trace",
failedExpectations: [],
passedExpectations: [],
trace: [
{timestamp: 1, message: 'msg 1'},
{timestamp: 100, message: 'msg 2'},
]
});
reporter.jasmineDone();

expect(this.out.getOutput()).toContain(' Trace:\n 1ms: msg 1\n 100ms: msg 2');
});

it('reports a summary without a "no expectations" message for a spec having passed expectations', function () {
const reporter = new ConsoleReporter();
reporter.setOptions({
Expand Down

0 comments on commit 18098bf

Please sign in to comment.