samedi 13 juin 2020

How to test formik yup validation error on blur?

I've written the following test:

it('validates the first name cannot be blank', () => {
    const { findByLabelText, getByText } = render(<Profile />);
    const firstName = findByLabelText('first name');
    firstName.value = '';
    fireEvent.blur(firstName);
    const error = getByText('First name is required');
    expect(error).not.toBeNull();
  });

After the test runs I get the error:

Unable to find the "window" object for the given node.

How do I get this test to pass?

Aucun commentaire:

Enregistrer un commentaire