Getbydisplayvalue React Testing Library Official

// Assert initial display value expect(screen.getByDisplayValue('Alice')).toBeInTheDocument();

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

// Edit the value await userEvent.clear(nameInput); await userEvent.type(nameInput, 'Bob'); // Assert initial display value expect(screen

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

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