# Testing Errors, with a Fresh Start for Every Test

An API's error answers, such as 400, 404 and 409 with their JSON bodies, are part of what it promises, so they get tests too, and beforeEach puts the in-memory data back before every test, so each one starts from the same seats.

![Cheat sheet: Testing Errors, with a Fresh Start for Every Test](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/300eb2f67dd64adcaa26bc998044793e.webp)

- Category: Node.js
- Level: Journeyman
- Tags: 400 Bad Request, 409 Conflict, Flaky Test, nodejs, Setup and Teardown, Test Isolation, unit testing
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-testing-errors-and-fresh-state-cheat-sheet
