Skip to content

Instantly share code, notes, and snippets.

@ruanlinos
Created June 24, 2022 22:25
Show Gist options
  • Save ruanlinos/bcfe1c6bcf13d5e96bb82be180f41d90 to your computer and use it in GitHub Desktop.
Save ruanlinos/bcfe1c6bcf13d5e96bb82be180f41d90 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