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 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.