Adding a form element
An HTML form is a bunch of fields wrapped in a form element. Even though we’re mostly interested in the fields, we need to start with the form element itself. That’s what we’ll build in this section.
Let’s create our first form by following these steps:
- Create a new file called
test/CustomerForm.test.jsand add the following scaffold. It contains all the usual imports and component test initialization that you’ve seen in the previous chapters:import React from "react"; import { initializeReactContainer, render, element, } from "./reactTestExtensions"; import { CustomerForm } from "../src/CustomerForm"; describe("CustomerForm", () => { beforeEach(() => { initializeReactContainer(); }); }); - Now you’re ready to create your first test. Add the following test to the
describeblock...