Soundorv0.13.0

user.tab

Moves keyboard focus with Tab, or back with Shift+Tab.

await user.tab(options?: { shift?: boolean }): Promise<void>;

Presses Tab (or Shift+Tab with shift: true): focus moves to the next (or previous) focusable node, as in the runtime, within the innermost trapping FocusScope.

await user.tab();
expect(screen.getByRole('adjustable', { name: 'Gain' })).toHaveFocus();
await user.tab({ shift: true });

Good to know

  • Tab through a UI to check its keyboard order, and that every control is reachable: assert where focus is with toHaveFocus.
  • A modal traps focus: Tab cycles inside it while it is open.

On this page