daw*_*daw 7 javascript unit-testing karma-runner
Karma将捕获写入console.log但不写入任何内容的任何消息console.error.我知道业力使用了引擎盖下的log4js.
有没有办法配置业力捕获console.error?
Voj*_*jta 11
Karma确实捕获console.error(参见https://github.com/karma-runner/karma/blob/415d0257c23ff7be07e240648bfff0bdefa9b0b6/client/karma.js#L70)
确保设置配置client.captureConsole: true并使用最新的Karma.
您可以console.error按照本博客文章中所述捕获。
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!")
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7259 次 |
| 最近记录: |