Skip to content

Instantly share code, notes, and snippets.

@ruanlinos
Created June 29, 2022 22:13
Show Gist options
  • Save ruanlinos/f2c9db13ca090a7cac85eb60e984c31b to your computer and use it in GitHub Desktop.
Save ruanlinos/f2c9db13ca090a7cac85eb60e984c31b to your computer and use it in GitHub Desktop.
import {shallow} from "enzyme";
import React, {ReactElement, ReactNode} from "react";
import {Input} from "../Input";
import * as Formik from 'formik';
describe('Input component testing', () => {
let wrapper: any;
const useFormikContextMock = jest.spyOn(Formik, 'useFormikContext');
beforeEach(() => {
useFormikContextMock.mockReturnValue({
errors: {
test: "error"
},
touched: {
test: true
},
})
})
it('should match with snapshot', () => {
const renderedComponent = shallow(
<Input name="test" label="Test"/>
)
expect(renderedComponent).toMatchSnapshot()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment