angular 4 unit testing error `TypeError: ctor is not a constructor`

This can be an error in the providers declarations.

When you try to mock a provider and use useClass instead of useValue the error “TypeError: ctor is not a constructor” is fired.

Here is an example that fires the error :

providers: [{provide: OrderService, useClass: new OrderServiceMock()}]

The correct declaration is :

providers: [{provide: OrderService, useValue: new OrderServiceMock()}]

Leave a Comment

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