Skip to content

Instantly share code, notes, and snippets.

@nnnnat
Created June 22, 2018 15:28
Show Gist options
  • Save nnnnat/fc035b7f96b39b2b099fc178ee529fb7 to your computer and use it in GitHub Desktop.
Save nnnnat/fc035b7f96b39b2b099fc178ee529fb7 to your computer and use it in GitHub Desktop.
Simple component interaction test using enzyme & jest
import React from "react";
import { shallow } from "enzyme";
import Button from "./Button";
const testClick = jest.fn();
test("Button component onClick", () => {
const component = shallow(<Button handleClick={testClick}>Button</Button>);
component.find("button").simulate("click");
expect(testClick).toHaveBeenCalled();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment