It's time to add some new tests!

We have a pretty good understanding of our initial test, but there's so much more we can learn by writing new tests! We'll start off by testing the absolute simplest component that we've written so far: our Todo component! You'll notice a pattern with how we have to name our tests to have Jest pick them up appropriately: we'll create a test for our Todo component (in src/Todo.js) as src/Todo.test.js! We'll almost always want to start off our tests by mimicking the structure in App.test.js, so we'll start off by doing almost the same things:

import React from "react";import ReactDOM from "react-dom";import Todo from "./Todo";it("renders without crashing", () => { const div = document.createElement("div");

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.