I'm trying to test this method:
doResetForm(){
this.form.reset();
}
so I tried:
it('should reset the form', () => {
const spyformReset = jest.spyOn(component.form, 'reset');
fixture.detectChanges();
component.doResetForm();
expect(spyformReset).toHaveBeenCalled();
}
but I'm getting the error:
Cannot spyon on a primitive value, undefined give
You can use spyOn to mock the method.
const spyformReset = spyOn(component.form, 'reset').and.callThrough();
component.doResetForm();
expect(spyformReset).toHaveBeenCalled();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With