Skip to content

Instantly share code, notes, and snippets.

View johnrom's full-sized avatar
🦃

John Rom johnrom

🦃
View GitHub Profile
import * as React from 'react';
import * as formik from 'formik';
jest.mock('formik');
it('prints error', () => {
formik.useFormikContext.mockResolvedValue({ errors: { hello: '' }});
const { container, rerender } = render(<Formik initialValues={{ hello: '' }}><YourErrorField name="hello" /></Formik>);
expect(container.querySelector('.error')?.textContent).toBe('');