Search⌘ K
AI Features

Selecting an Option in a select Element

Understand how to simulate user interactions by selecting options within single and multi-select elements in React forms. This lesson guides you through using user-event's selectOptions function to write effective Jest tests that ensure correct form submission with chosen options.

The starter project contains the same ContactForm component as the previous lesson. It also includes a half-implemented test that checks that the form is successfully submitted.

A copy of the code is in the code widget below. Click the “Run” button to run the tests.

export default "test-file-stub";
Half implemented test

Filling in the Department

...