Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
Formik test returning "You seem to have overlapping act() calls, this is not supported"

I have a simple form im trying to test:

Form:

<Formik
    enableReinitialize
    onSubmit={(values, actions) => {
        console.log('---DEBUG---');
        onSubmit(values, actions);
    }}
    validationSchema={ValidationSchema}
    >
        {(formik) => {
            const { errors } = formik;

            return (
                <Form noValidate autoComplete="off">
                    {/* USER PICKER */}
                    <FastField
                        id="name"
                        name="name"
                        type="text"
                        onChange={({ event, value }) => {
                            handleChange(event);
                            setUserIdOrName(value);
                        }}
                        value={values.name}
                        errorMessage={
                        !!errors.name && !!touched.name
                            ? errors.name
                            : ''
                        }
                        as={TextField}
                    />
                    {/* SUBMIT BUTTON */}
                    <Button
                        color="red"
                        type="submit"
                        onClick={() => { console.log('-----CLICKED----'); }}
                    />
                </Form>
            );
        }}
</Formik>

Test:

  it.only('shows required error messages', async () => {
    render(<MyForm />);

    const button = screen.getByRole('button');
    userEvent.click(button);

    // Formik and Yup validation are async methods
    const required = await screen.findByText(/required/i);
    expect(required).toBeInTheDocument();
  });

Error:

console.error Warning: You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one.

TestingLibraryElementError: Unable to find an element with the text: /required/i. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try with:

it.only('shows required error messages', async () => {
    render(<MyForm />);

    const button = screen.getByRole('button');
    await userEvent.click(button);

    // Formik and Yup validation are async methods
    const required = await screen.findByText(/required/i);
    expect(required).toBeInTheDocument();
  });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda