Skip to content

Instantly share code, notes, and snippets.

@RichardBray
Last active April 2, 2020 08:05
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 RichardBray/194db1fe9fe06f7166a5d42e87cf1ec6 to your computer and use it in GitHub Desktop.
Save RichardBray/194db1fe9fe06f7166a5d42e87cf1ec6 to your computer and use it in GitHub Desktop.
// App.test.js
import React from "react";
import Enzyme, { mount } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import data from "./data.json";
import App from "./App";
Enzyme.configure({ adapter: new Adapter() });
describe("App", () => {
const wrapper = mount(<App />);
test("Renders all the Questions provided in the data", () => {
// - when
const questionComp = wrapper.find("Question");
const totalQuestions = data.results.length;
// - then
expect(questionComp).toHaveLength(totalQuestions);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment