I have the following code ...
export class LoginComponent { userName: string; password: string; rememberMe: boolean = false; constructor( private auth: AuthenticationService, private router: Router) { ... } ... }
I am trying Unit test but my first attempt failed ....
beforeEach(() => { router = new Router(); component = new LoginComponent(authService, router); });
Because he needs parameters for the Router constructor. Here I saw ...
beforeEach(() => addProviders([ APP_ROUTER_PROVIDERS, // must be first {provide: APP_BASE_HREF, useValue: '/'}, // must be second {provide: ActivatedRoute, useClass: Mock}, {provide: Router, useClass: Mock} ]));
But I don't seem to have APP_ROUTER_PROVIDERS or Mock anywhere in my dependencies, so I think it might be deprecated (or I need the dependencies).
How am I mocking this? It doesn’t even matter for the test I'm working on.
source share