Created
February 11, 2026 19:00
-
-
Save claudiainbytes/a3eda4579b3e3e447e522218a7143a2a to your computer and use it in GitHub Desktop.
Testing Keyboard Navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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