Browser Mode Context Module

Vitest Browser Mode has a context module that you can import from vitest/browser.

This is a useful advanced feature that exposes a few functions and utilities.

This module lets you access things such as:

  • userEvent (covered in detail in a previous lesson, but we will explain how to access it via this context module)
  • commands (for things like file handing and accessing the Chrome Devtools Protocol)
  • the page export
  • frameLocator method to access elements inside the iframe (for the playwright provider)
  • access the Chrome DevTools Protocol session
  • and the list of utils functions, which includes functions to output a nice pretty HTML string of the DOM.

Loading full lesson...