Skip to content

Cannot read property 'when' of undefined #671

@marius-hi

Description

@marius-hi

I'm running a project that uses angular hybrid with the following versions:

  • "angular": "1.8.0"
  • "@angular/core": "10.0.3"
  • "@uirouter/angular-hybrid": "11.0.2"
  • "@uirouter/angular": "7.0.0"
  • "@uirouter/angularjs": "1.0.28"
    ....

When executing unit tests I'm getting "Cannot read property 'when' of undefined" in most of the tests (karma with chai and mocha). I tried to debug and see that is pointing to node_modules/@uirouter/core/lib-esm/resolve/resolvable.js
this.promise = this.resolved ? services.$q.when(this.data) : undefined; ( https://github.com/ui-router/core/blob/master/src/resolve/resolvable.ts#L84 )
If I guard against this.resolved the error is gone
this.promise = this.resolved && services ? services.$q.when(this.data) : undefined;

Could you suggest in which cases services can be undefined and if this can be fixed on master?
Should I create a pull request for it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions