you can use jasmine spyObj. In you TestBed
:
providers:[
{
provide: Router,
usevalue: jasmine.createSpyObj('Router',['methodOne','methodTwo]),
},
],
in beforeEach:
router = fixture.debugElement.injector.get(Router);
in the test:
it('should...', ()=> {
(router.methodOne as Spy).and.returnValue(whateverValue)// if you wanna mock the response
});
source
share