Karma will capture any messages written to console.log
but not anything written to console.error
. I understand that karma uses log4js under the hood.
Is there any way to configure karma to capture console.error
?
Karma does capture console.error
(see https://github.com/karma-runner/karma/blob/415d0257c23ff7be07e240648bfff0bdefa9b0b6/client/karma.js#L70)
Make sure you set config client.captureConsole: true
and use the latest Karma.
You could capture the console.error
as described in this blog post
describe('TestSuite', function() {
var oldError = console.error;
beforeEach(function() {
console.error = function(message) {
throw new Error(message);
};
});
return afterEach(function() {
return console.error = oldError;
});
it('should fail', function() {
console.error("Oops!")
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With