Print afterAllExceptions to the console.
- Add afterAllException function to ConsoleReporter - Print the stack traces of the errors at the end of the console output [#67055730]
This commit is contained in:
+14
-2
@@ -54,7 +54,8 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
red: '\x1B[31m',
|
red: '\x1B[31m',
|
||||||
yellow: '\x1B[33m',
|
yellow: '\x1B[33m',
|
||||||
none: '\x1B[0m'
|
none: '\x1B[0m'
|
||||||
};
|
},
|
||||||
|
exceptionList = [];
|
||||||
|
|
||||||
this.jasmineStarted = function() {
|
this.jasmineStarted = function() {
|
||||||
specCount = 0;
|
specCount = 0;
|
||||||
@@ -84,9 +85,16 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
printNewline();
|
printNewline();
|
||||||
var seconds = timer.elapsed() / 1000;
|
var seconds = timer.elapsed() / 1000;
|
||||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
|
|
||||||
|
exceptionList.forEach(function(error) {
|
||||||
|
printNewline();
|
||||||
|
print(colored('red', 'An error was thrown in an afterAll'));
|
||||||
|
printNewline();
|
||||||
|
print(colored('red', error.stack));
|
||||||
|
printNewline();
|
||||||
|
});
|
||||||
|
|
||||||
onComplete(failureCount === 0);
|
onComplete(failureCount === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,6 +119,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.afterAllException = function(error) {
|
||||||
|
exceptionList.push(error);
|
||||||
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
function printNewline() {
|
function printNewline() {
|
||||||
|
|||||||
@@ -176,9 +176,7 @@ describe("ConsoleReporter", function() {
|
|||||||
expect(onComplete).toHaveBeenCalled();
|
expect(onComplete).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("with color", function() {
|
describe("with color", function() {
|
||||||
|
|
||||||
it("reports that the suite has started to the console", function() {
|
it("reports that the suite has started to the console", function() {
|
||||||
var reporter = new j$.ConsoleReporter({
|
var reporter = new j$.ConsoleReporter({
|
||||||
print: out.print,
|
print: out.print,
|
||||||
@@ -222,5 +220,21 @@ describe("ConsoleReporter", function() {
|
|||||||
|
|
||||||
expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
|
expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("displays all afterAll exceptions", function() {
|
||||||
|
var reporter = new j$.ConsoleReporter({
|
||||||
|
print: out.print,
|
||||||
|
showColors: true
|
||||||
|
}),
|
||||||
|
error = new Error('After All Exception'),
|
||||||
|
anotherError = new Error('Some Other Exception');
|
||||||
|
|
||||||
|
reporter.afterAllException(error);
|
||||||
|
reporter.afterAllException(anotherError);
|
||||||
|
reporter.jasmineDone();
|
||||||
|
|
||||||
|
expect(out.getOutput()).toMatch(/After All Exception/);
|
||||||
|
expect(out.getOutput()).toMatch(/Some Other Exception/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+9
-1
@@ -47,7 +47,15 @@ var jasmineInterface = {
|
|||||||
|
|
||||||
jsApiReporter: new jasmine.JsApiReporter({
|
jsApiReporter: new jasmine.JsApiReporter({
|
||||||
timer: new jasmine.Timer()
|
timer: new jasmine.Timer()
|
||||||
})
|
}),
|
||||||
|
|
||||||
|
beforeAll: function(beforeAllFunction) {
|
||||||
|
return env.beforeAll(beforeAllFunction);
|
||||||
|
},
|
||||||
|
|
||||||
|
afterAll: function(afterAllFunction) {
|
||||||
|
return env.afterAll(afterAllFunction);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extend(global, jasmineInterface);
|
extend(global, jasmineInterface);
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
red: '\x1B[31m',
|
red: '\x1B[31m',
|
||||||
yellow: '\x1B[33m',
|
yellow: '\x1B[33m',
|
||||||
none: '\x1B[0m'
|
none: '\x1B[0m'
|
||||||
};
|
},
|
||||||
|
exceptionList = [];
|
||||||
|
|
||||||
this.jasmineStarted = function() {
|
this.jasmineStarted = function() {
|
||||||
specCount = 0;
|
specCount = 0;
|
||||||
@@ -49,9 +50,16 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
printNewline();
|
printNewline();
|
||||||
var seconds = timer.elapsed() / 1000;
|
var seconds = timer.elapsed() / 1000;
|
||||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||||
|
|
||||||
printNewline();
|
printNewline();
|
||||||
|
|
||||||
|
exceptionList.forEach(function(error) {
|
||||||
|
printNewline();
|
||||||
|
print(colored('red', 'An error was thrown in an afterAll'));
|
||||||
|
printNewline();
|
||||||
|
print(colored('red', error.stack));
|
||||||
|
printNewline();
|
||||||
|
});
|
||||||
|
|
||||||
onComplete(failureCount === 0);
|
onComplete(failureCount === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,6 +84,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.afterAllException = function(error) {
|
||||||
|
exceptionList.push(error);
|
||||||
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
function printNewline() {
|
function printNewline() {
|
||||||
|
|||||||
Reference in New Issue
Block a user