Based on the idea of dtabuenc's answer, I applied a workaround that dumped logs for Jasmine's tests that fail, in the form of global afterEach ():
afterEach(inject(function ($log) {
if (this.results().failedCount) {
var out = [];
angular.forEach(["log", "info", "warn", "error", "debug"], function (logLevel) {
var logs = $log[logLevel].logs;
if (!logs.length)
return;
out.push(["*** " + logLevel + " ***"]);
out.push.apply(out, logs);
out.push(["*** /" + logLevel + " ***"]);
});
if (out.length) {
console.log("*** logs for: " + this.description + " ***");
angular.forEach(out, function (items) { console.log.apply(console, items); });
}
}
$log.reset();
}));
Unfortunately, without replacing the angular -mocks' $ log implementation, the order of messages with different levels of the log is lost, but I think I can live with it. Disabling all log messages, including Angular's own errors and warnings during tests, still sounds like a bad design choice, though.
source
share