Soundorv0.13.0

user.type

Clicks a text input and types text into it, character by character.

await user.type(input: NodeTarget, text: string): Promise<void>;

Clicks the text input, which focuses it, then types text one character at a time, each a key down and up that the input edits itself with, as it does for a user.

const name = screen.getByRole('textinput', { name: 'Preset name' });
await user.clear(name);
await user.type(name, 'Warm');
await user.keyboard('{Enter}');

Good to know

  • The text is literal: { and [ are typed as they are. For Enter, arrows or held keys, use keyboard.
  • It does not empty the input first: clear it to replace its text.
  • Only a TextInput: typing into another node throws.

On this page