Angular 2+单元测试:禁用控制台日志

时间:2018-01-09 16:08:22

标签: angular mocha karma-runner

当我运行ng test并且我的一些测试不起作用时,我遇到了一个问题:日志显示在我的控制台中。这是一个例子:

× should be created
Chrome 63.0.3239 (Windows 10 0.0.0) ConfirmationDialogService should be created FAILED
        Error: StaticInjectorError[MatDialog]:
          StaticInjectorError[MatDialog]:
            NullInjectorError: No provider for MatDialog!
            at _NullInjector.webpackJsonp.../../../core/esm5/core.js._NullInjector.get C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:993:1)
            at resolveToken C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:1281:1)
            at tryResolveToken C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:1223:1)
            at StaticInjector.webpackJsonp.../../../core/esm5/core.js.StaticInjector.get C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:1094:1)
            at resolveToken C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:1281:1)
            at tryResolveToken C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:1223:1)
            at StaticInjector.webpackJsonp.../../../core/esm5/core.js.StaticInjector.get C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:1094:1)
            at resolveNgModuleDep C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:10878:1)
            at _createClass C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:10915:1)
            at _createProviderInstance$1 C:/Users/MT4E45CN/Documents/Projects/POC/node_modules/@angular/core/esm5/core.js:10889:1)

我想从我的控制台删除此跟踪,因为我不需要它:我已经设置了我的记者,只给出了错误的第一行。

有没有办法禁用这些日志? (我认为它们来自chrome控制台,但顺便说一下我可能错了)。

PS:我试图用

禁用它们
client: {
  captureConsole: false
},

在我的业力配置中,但它不起作用。

0 个答案:

没有答案