In my app.component.ts I have the following ngOnInit function:
ngOnInit() {
this.sub = this.router.events.subscribe(e => {
if (e instanceof Navi
This is a really old question but I just came across it looking for something better than what i have and in my case i need to test several different events. My basic approach was just to change the Router.events to a non read only value like
(router as any).events = new BehaviorSubject(null);
fixture.detectChanges();
router.events.next(new NavigationEnd(0, 'http://localhost:4200/login',
'http://localhost:4200/login'));
expect(comp.loggedIn).toEqual(true);
Hope maybe that helps someone. I couldn't find an easier solution after looking around