A bug fix demonstrates that one observed failure has been addressed. A regression test turns that observation into a repeatable check against future changes.
Implementation approach
Reproduce the original failure with the smallest realistic fixture. Assert the intended behavior rather than an incidental implementation detail, then verify the test fails before the fix and passes afterward.
Example
expect(calculateTotal([{ price: 100, quantity: 2 }])).toBe(200);
Validation and edge cases
Include edge cases that share the same failure mechanism, but avoid expanding one bug test into an unrelated integration suite. Run the affected tests in CI.
Key takeaway
Write the test description in terms of the behavior a user or caller expects.




