What is a unit test?
Code that checks that one small part of your program, usually a single function, does what it should.
You fix one bug, and quietly create two more somewhere else. Unit tests are how developers find out before their users do.
What it is
A unit test is a small piece of code that checks that one small part of your program, usually a single function, does what it should.
How it works
Say a function adds 8 percent tax to a price. A test calls it with $100, and checks that the answer is exactly $108. Another test tries zero, or a negative number. A test runner, like Jest or pytest, runs hundreds of these in seconds, and shows you exactly which ones failed.
Why it matters
Tests run automatically on every change, often in CI, so a broken feature gets caught in minutes. And they let you clean up old code without fear.










