mardi 9 août 2016

Angular 2 - Error Invalid provider unit test

I'm working on a project with Angular 2 RC4 generate by Angular-Cli, and i have the same error on each of my unit test.

Error: Invalid provider - only instances of Provider and Type are allowed, got: [object Object] (line 170)

Here is a simple example of one spec :

import {addProviders,inject} from "@angular/core/testing";
import {AppComponent} from "./app.component";

beforeEach(() => {
  addProviders([AppComponent])
});

describe('Component : App', () => {
  it('should created an instance',
    inject([AppComponent], (app:AppComponent) => {
      expect(app).toBeTruthy();
    }));

});

This error appears on each spec which need providers.

PS : The tests worked correctly in Angular 2 RC3

Thanks for your help !

Aucun commentaire:

Enregistrer un commentaire