1

I'm running a unit test and its failing with some zone.js gumpf.

how can i get the real error?

error is ...

× 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
danday74
  • 52,471
  • 49
  • 232
  • 283

2 Answers2

2

This error happened because I was doing ...

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

I was thus using the injected service before it was ready.

Changing it to ...

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

Fixed it. An error message would have helped. Wasted 3 hours.

Comeon Zone.JS and ng2, sort it out!

danday74
  • 52,471
  • 49
  • 232
  • 283
2

from zone.js 0.8.1 (the newest release), the error.stack will remove most zone related stack frames, please try it. https://github.com/angular/zone.js/commit/76fa891b88f85bb975ac69c23e620c915e71bf84

jiali passion
  • 1,691
  • 1
  • 14
  • 19