lecture 4 of 180 completed

Fixtures: setup that cleans up after itself

Custom fixtures give each test what it needs and take it away afterwards, without repeating code.

What you'll learn

  • How a custom fixture replaces repeated setup
  • Why setup and teardown belong in one function
  • How a test declares only what it needs

Open your test files and count how many times you see this:

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →