How to select an option from a select list with React Testing Library
Add data-testid to the options <option data-testid=”select-option” key={item.key} value={item.key}> {item.label} </option> Then, in the test call fireEvent.change, get all the options by getAllByTestId and check the selected option: import React from ‘react’; import { render, fireEvent } from ‘@testing-library/react’; import App from ‘./App’; test(‘Simulates selection’, () => { const { getByTestId, getAllByTestId } = render(<App … Read more