...

/

Introduction and Clicking Elements

Introduction and Clicking Elements

Learn two different approaches for simulating a DOM click event in a test and determine the best approach in this lesson.

The starter project contains a ContactForm component that captures some information and displays a “Save” button to submit it. A half-implemented test checks that a validation error appears for a Name field when it isn’t filled when the form is submitted.

A copy of the project is in the code widget below. Clicking the “Run” button will run the app and display the form.

export default "test-file-stub";
Contact form

Run the app and click the “Save” button without filling in the form. We will see validation errors alongside the Name and Message fields:

Notice also that the MouseDown event has been output to the console. The MouseDown event is handled as follows on the “Save” button:

 ...
Access this course and 1400+ top-rated courses and projects.