Vitest Browser Mode Locators - The Interactive Methods

So far in this course we have shown how to render components in Vitest Browser Mode and how to query to select specific elements.

Now let's add some interaction!

In this lesson we're going to go over the main interactive methods (like .click()).

These work in a similar way to Playwright's API, but quite differently to React Testing Library, which encourages you to use patterns like userEvent.click(element). In Vitest Browser Mode, the most common way to interact (with things like clicking) is to call .click() on the Locator itself.

await screen
  .getByRole('button')
  .click();

Lesson covers:

clear(), click(), dblClick(), dropTo(), fill(), hover(), selectOptions(), unhover()

Loading full lesson...