Angular Karma ng测试不会在控制台中显示构建错误
我正在使用Karma和Jasmine在我的Angular 7项目中执行测试。然而,我遇到了一个非常令人恼火的场景,如果Angular Karma ng测试不会在控制台中显示构建错误,angular,typescript,karma-jasmine,Angular,Typescript,Karma Jasmine,我正在使用Karma和Jasmine在我的Angular 7项目中执行测试。然而,我遇到了一个非常令人恼火的场景,如果.spec.ts(或.ts)文件中有任何错误,运行ng test不会在控制台中显示这些错误 例如,如果文件中存在重复导入: import { DatepickerModule } from 'ngx-bootstrap'; import { DatepickerModule } from 'ngx-bootstrap'; @Component({...}) export cla
.spec.ts
(或.ts
)文件中有任何错误,运行ng test
不会在控制台中显示这些错误
例如,如果文件中存在重复导入:
import { DatepickerModule } from 'ngx-bootstrap';
import { DatepickerModule } from 'ngx-bootstrap';
@Component({...})
export class MyComponent { ... }
正常的ng serve
将此报告为错误。但是,运行ng test
并不总是这样做,它只是无法运行测试,打开一个空白页面,说“正在等待本地主机…”
,然后最终失败:
> ng test
10 % building modules 3 / 3 modules 0 active30 08 2019 11: 28: 31.213: WARN[karma]: No captured browser, open http://localhost:9876/
30 08 2019 11: 28: 31.296: INFO[karma - server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
30 08 2019 11: 28: 31.297: INFO[launcher]: Launching browsers Chrome with concurrency unlimited
10 % building modules 4 / 5 modules 1 active ...b\projects\myProject\src\styles.scss30 08 2019 11: 28: 31.720: INFO[launcher]: Starting browser Chrome
30 08 2019 11: 29: 31.722: WARN[launcher]: Chrome have not captured in 60000 ms, killing.
30 08 2019 11: 29: 31.994: INFO[launcher]: Trying to start Chrome again(1 / 2).
30 08 2019 11: 30: 31.996: WARN[launcher]: Chrome have not captured in 60000 ms, killing.
30 08 2019 11: 30: 32.277: INFO[launcher]: Trying to start Chrome again(2 / 2).
30 08 2019 11: 31: 32.279: WARN[launcher]: Chrome have not captured in 60000 ms, killing.
30 08 2019 11: 31: 32.530: ERROR[launcher]: Chrome failed 2 times(timeout).Giving up.
这使得我们很难理解为什么Karma没有启动测试,只是打开了一个空白窗口,其中隐藏的信息Chrome在60000毫秒内没有捕获,导致死亡。
我曾尝试从设置日志级别,但它甚至没有达到加载业力的程度,因为实际构建在此之前失败(我认为)
如何让构建在spec.ts
文件中报告这些错误
编辑
使用
--watch=false运行命令会报告编译错误。类似地,如果在规范文件中进行更改,导致触发重建(如果您有--watch=true
),编译错误也会通过cli在控制台中打印出来。这不是理想的解决方案,但这从原始问题起作用:
使用--watch=false运行命令会报告编译错误。类似地,如果在spec文件中进行更改,导致触发重建(如果有--watch=true
),编译错误也会通过cli在控制台中打印出来