Skip to content

Instantly share code, notes, and snippets.

@gildniy
Last active October 31, 2019 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gildniy/c815a960bd98a24ee57bed6e0983c5c9 to your computer and use it in GitHub Desktop.
Save gildniy/c815a960bd98a24ee57bed6e0983c5c9 to your computer and use it in GitHub Desktop.
Testing a React Functional Component using Enzyme
import React from 'react';
import {shallow} from "enzyme";
const numbersArr = ["One", "Two", "Three"];
const Count123array = () => (
<div className="my-text">
{numbersArr[1]}
</div>
);
describe("['One', 'Two', 'Three']", () => {
test("Should have 'Two' as innerText", () => {
const wrapper = shallow(<Count123array/>);
const myText = wrapper.find(".my-text");
expect(myText.exists()).toBe(true);
expect(myText.text()).toBe("Two");
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment