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

时间:2016-12-09 14:02:30

标签: angular 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

2 个答案:

答案 0 :(得分:2)

发生此错误是因为我正在做...

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

因此我在准备好之前使用了注入的服务。

将其更改为...

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

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

Comeon Zone.JS和ng2,整理出来!

答案 1 :(得分:2)

来自zone.js 0.8.1(最新版本)的

,error.stack将删除大多数与区域相关的堆栈帧,请尝试一下。 https://github.com/angular/zone.js/commit/76fa891b88f85bb975ac69c23e620c915e71bf84