Getbydisplayvalue React Testing Library |link| -

test('select element by display value', () => render(<RoleSelect defaultValue="Admin" />);

// Assert initial display value expect(screen.getByDisplayValue('Alice')).toBeInTheDocument(); getbydisplayvalue react testing library

const nameInput = screen.getByLabelText(/name/i); test('select element by display value'

// Edit the value await userEvent.clear(nameInput); await userEvent.type(nameInput, 'Bob'); RoleSelect defaultValue="Admin" /&gt

// Assert updated display value expect(screen.getByDisplayValue('Bob')).toBeInTheDocument(); );