1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular unit test - how to test reactive form reset method?

Discussão em 'Angular' iniciado por paulotarcio, Outubro 3, 2024 às 18:33.

  1. paulotarcio

    paulotarcio Guest

    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

    Continue reading...

Compartilhe esta Página