Skip to content

Angular CLI launched unit tests throw when NgRedux is injected #213

Closed
@CalvinDale

Description

@CalvinDale

I'm getting the following error when I run unit tests in an Angular-CLI-created project that injects NgRedux into its main AppComponent.

D:\VST\IssueDemoProj>ng test

Chrome 53.0.2785 (Windows 7 0.0.0) ERROR: 'Unhandled Promise rejection:', TypeError{}, 
'; Zone:', '<root>', '; Task:', 'Promise.then', '; Value:', TypeError{}
...
D:\> ng -v
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: win32 x64

I'm not sure what the root cause might be...but so far I've only experienced this issue if I inject NgRedux.

Steps to reproduce

  1. ng new IssueDemoProj
  2. cd IssueDemoProj
  3. ng serve (fails with TypeScript issues)
    • refer to this issue
    • Fix by uninstalling and re-installing TypeScript
      • npm uninstall --save-dev typescript
      • npm install --save-dev typescript@beta
      • ng serve works now
  4. ng test (different console while ng serve is still active, runs ok)
  5. npm i --save redux ng2-redux
  6. In AppModule,
    • import { NgRedux } from 'ng2-redux';
    • @NgModule({ ... providers: [NgRedux] ... })
  7. In AppComponent,
    • import { NgRedux } from 'ng2-redux';
    • constructor(private ngRedux: NgRedux<{ prop1: string }>) { }
  8. ng test (fails now)
    • Reports different error than aforementioned 'Unhandled Promise rejection:'...
    • To see above error, fix up \node_modules\karma\lib\reporter.js to handle objects per this issue
      • Just above msg = (msg || '').replace(... line, insert if (msg && typeof (msg) !== 'string') { msg = JSON.stringify(msg); }
  9. In AppComponent, delete the constructor
    • I.e., remove private ngRedux: NgRedux<{ prop1: string }> injection
  10. ng test (works now)

Any ideas as to what might be the root cause here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions