Got it working! Had I used console.log
directly it would have worked but now that I am using $log
I had to patch it in a beforeEach
(looks like by default it wasn't wired by angularjs):
$provide.value('$log', console);
Question
In a project based on angular-seed project, I am running unit tests with ./scripts/test.sh --log-level debug
but none of the log messages that I see are coming from my app. How do I get to see them? In my app, I am logging with $log
.
Solution 2
Got it working! Had I used console.log
directly it would have worked but now that I am using $log
I had to patch it in a beforeEach
(looks like by default it wasn't wired by angularjs):
$provide.value('$log', console);
OTHER TIPS
Thanks. As mentioned, tests can inject console
for $log
using $provide
. For posterity, $provide
is not available via inject(function(...) { ... })
but instead must be injected into a function argument to module
:
beforeEach(module('myapp', function($provide) {
// Output messages
$provide.value('$log', console);
}));
for clarity, you must structure it like this:
beforeEach(module('myapp'));
beforeEach(module('myapp', function($provide) {
// Output messages
$provide.value('$log', console);
}));