如何停止 zone.js 吞下你的错误 invoke@node_modules/zone.js

How to stop zone.js swallowing your errors invoke@node_modules/zone.js

我正在 运行 进行单元测试,但因 zone.js gumpf 而失败。

我怎样才能得到真正的错误?

错误是...

× should instantiate service
      PhantomJS 2.1.1 (Windows 7 0.0.0)
    e
    invoke@node_modules/zone.js/dist/zone.js:232:31
    onInvoke@node_modules/zone.js/dist/proxy.js:79:45
    invoke@node_modules/zone.js/dist/zone.js:231:40
    run@node_modules/zone.js/dist/zone.js:114:49
    node_modules/zone.js/dist/jasmine-patch.js:102:37
    execute@node_modules/zone.js/dist/jasmine-patch.js:132:46
    execute@node_modules/zone.js/dist/jasmine-patch.js:132:46
    execute@node_modules/zone.js/dist/jasmine-patch.js:132:46
    invoke@node_modules/zone.js/dist/zone.js:232:31
    run@node_modules/zone.js/dist/zone.js:114:49
    node_modules/zone.js/dist/zone.js:502:60
    invokeTask@node_modules/zone.js/dist/zone.js:265:40
    runTask@node_modules/zone.js/dist/zone.js:154:57
    drainMicroTaskQueue@node_modules/zone.js/dist/zone.js:401:42
    run@node_modules/core-js/client/shim.js:4005:30
    node_modules/core-js/client/shim.js:4018:32
    flush@node_modules/core-js/client/shim.js:4373:12

发生这个错误是因为我在做...

public this.getDocuments$ = this.streamCreatorService.etc
constructor(private streamCreatorService: StreamCreatorService) {
}

因此我在注入的服务准备就绪之前使用它。

正在将其更改为...

public this.getDocuments$;
constructor(private streamCreatorService: StreamCreatorService) {
}
ngOnInit() {
    this.getDocuments$ = this.streamCreatorService.etc
}

已修复。错误消息会有所帮助。浪费了3个小时。

加油 Zone.JS 和 ng2,整理一下!

从zone.js 0.8.1(最新版本)开始,error.stack将删除大部分与区域相关的堆栈帧,请尝试。 https://github.com/angular/zone.js/commit/76fa891b88f85bb975ac69c23e620c915e71bf84