Test Case
In one line
A test case is one individual test — it checks one specific thing, like 'add(2, 3) returns 5'.
In simple words
A test case is the smallest unit of testing. It's one test that checks one specific behavior. For example, 'when I add 2 and 3, I get 5' is a test case.
Each test case has three parts: setup (prepare the data), execution (call the code), and assertion (check the result). A test case either passes (the assertion was true) or fails (the assertion was false).
Good test cases are focused — each one tests one thing. If a test case fails, you should immediately know what behavior is broken. Test cases live inside test suites.
Example
test('returns 5 when adding 2 and 3', () => {
expect(add(2, 3)).toBe(5);
});This is one test case — it checks one specific behavior of the add function.
Related terms
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.