# Setup and Teardown

*phrase*

say it: **“SET-up and TAIR-down”** **/ˈsɛtʌp ænd ˈtɛərdaʊn/**

Code that runs before each test to get things ready and after each test to clean up, so one test can't spoil the next.

## What is **Setup and Teardown**?

**Setup** runs before each test (creating objects) and **teardown** after (cleaning up), so tests don't affect each other.

## In a sentence

- “The **setup and teardown** give every test a fresh, empty cart and clear the page afterward.”
- “I moved the repeated lines into **setup and teardown** with beforeEach and afterEach.”

Level: Journeyman · [More Unit Testing terms at this level](https://www.ask-codey.com/glossary?category=unit-testing&level=3)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/setup-and-teardown
