Skip to content

Instantly share code, notes, and snippets.

@claudiainbytes
Created February 11, 2026 19:00
Show Gist options
  • Select an option

  • Save claudiainbytes/a3eda4579b3e3e447e522218a7143a2a to your computer and use it in GitHub Desktop.

Select an option

Save claudiainbytes/a3eda4579b3e3e447e522218a7143a2a to your computer and use it in GitHub Desktop.
Testing Keyboard Navigation
it('navega con teclado', async () => {
const user = userEvent.setup()
render(<Dropdown options={['Option 1', 'Option 2', 'Option 3']} />)
const trigger = screen.getByRole('button', { name: /select/i })
// Abrir con Enter
await user.click(trigger)
// Navegar con flechas
await user.keyboard('{ArrowDown}')
await user.keyboard('{ArrowDown}')
// Seleccionar con Enter
await user.keyboard('{Enter}')
expect(screen.getByText('Option 2')).toBeInTheDocument()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment