Fixture
ELI5 — The Vibe Check
A fixture is like pre-built test furniture. Instead of building a whole fake user every single test, you set up the furniture once (a fake user, a fake database state) and all your tests just sit in the already-furnished room.
Real Talk
A fixture is reusable test data or state that is set up before tests run and potentially torn down afterward. Fixtures can be static data files (JSON, SQL) or setup/teardown functions that create a known starting state for tests.
Show Me The Code
// fixtures/users.json
{
"adminUser": {
"id": 1,
"name": "Admin",
"role": "admin"
},
"regularUser": {
"id": 2,
"name": "Alice",
"role": "user"
}
}
When You'll Hear This
"Load the user fixture so all auth tests start with the same data." / "Fixtures keep test data consistent and version-controlled."
Related Terms
Mock
A mock is a fake version of something your code talks to.
Stub
A stub is like a cardboard cutout of a function. It stands in for the real thing and always gives you the same canned response.
Test Environment
A test environment is a separate version of your app just for running tests.
Test Suite
A test suite is just a collection of related tests grouped together.