Vitest Browser Mode
Learn everything you need to know to get up to speed with Vitest Browser Mode, to run your tests in a very realistic, fast and (optionally) visual way!
Vitest Browser Introduction
Vitest Browser Mode Setup
Vitest Browser Mode Fundamentals
Vitest Browser Mode Locators
Vitest Browser Mode Assertions
Vitest Browser Mode Interactivity
Vitest Browser Mode Advanced
When you query for elements with functions like getByRole() or getByText(), they return a Locator object.
Normally that is all you will need for querying specific elements in your tests. However, there will be times when selecting elements needs a bit more filtering or specificity.
There are several modifier methods that you can call on the Locator object to refine the query, like nth(0) or first() (both get the first element), and() to combine two Locator matches, or filter() to filter a specific element from a list.
Knowing and understanding them is very important for writing correct tests that are easy to read.
In this lesson, we will cover them and how to use them.