Adding tests for NewTodo

At last, we can add our final test suite and make sure NewTodo is covered as well. For the most part, we'll work with the same skeleton we already have and have used before. Create src/NewTodo.test.js and give it the following skeleton:

import React from "react";import ReactDOM from "react-dom";import { shallow } from "enzyme";import renderer from "react-test-renderer";import NewTodo from "./NewTodo";describe(NewTodo, () => {  const mockAddTodo = jest.fn();  const component = shallow(<NewTodo addTodo={mockAddTodo} />);  it("renders without crashing", () => {    const div = document.createElement("div");    ReactDOM.render(<NewTodo addTodo={mockAddTodo} />, div);    ReactDOM.unmountComponentAtNode(div);  }); it("renders and matches ...

Get Create React App 2 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.