Testing is used to check whether your code works as expected β
In simple words
Testing helps developers
find bugs before users do π§
Without testing β
β’ Hidden bugs
β’ Unexpected crashes
β’ Poor user experience
π§ Why Testing Is Important
β’ Improves code quality β¨
β’ Prevents future bugs π
β’ Makes refactoring safe π
β’ Builds developer confidence πͺ
π§ͺ Types of Testing
β’ Unit testing - tests small parts of code
β’ Integration testing - tests modules together
β’ End to end testing - tests full user flow
π Real World Examples
β’ Checking login functionality
β’ Verifying API responses
β’ Testing payment flow
β’ Ensuring UI buttons work
π Basic Testing Flow
Write feature βοΈ
Write test for it π§ͺ
Run tests βοΈ
Fix bugs if tests fail π§
π» Example: Simple Test using Jest
function sum(a, b) {
return a + b;
}
test("adds two numbers", () => {
expect(sum(2, 3)).toBe(5);
});