Invalid provider for the NgModule ‘DynamicTestModule’ when testing a service in Angular 2

This is such an annoying error, thought I’d include another subtle cause to look for in your spec. In my case I specified providers instead of the correct value of provide as below

 TestBed.configureTestingModule({
      providers: [{provider: ApplicationActions, useClass: ActionMock}]

rather than offer useful information like “no ‘provide’ key specified” it simply reports

Failed: Invalid provider for the NgModule ‘DynamicTestModule’ – only
instances of Provider and Type are allowed, got: [?[object Object]?,
…]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)