What is Testing? And Why Do We Use Jest?
When we write code, we expect it to work the way we imagine.
What is Testing? And Why Do We Use Jest?
In this post, we’ll understand what testing really means and why developers use a tool like Jest. I’ll explain everything in simple words, using the same Expense Tracker example that we’ll follow throughout the whole series.

Why Testing Exists
When we write code, we expect it to work the way we imagine.
But sometimes our brain thinks one thing, and our code does something else.
Testing is simply a way to check our own work.
Think of it like this 👇
When you do a simple maths calculation like:
100 + 200 = 300You quickly double-check in your head:
“Does this look right?”
“Is the number correct?”
That small check you do in your mind is basically a test.
In programming, we do the same thing — but with code.
What is a test?
A test is a small piece of code that checks another piece of code.
You give it an input → you expect an output.
Example:
- Input: “expenses are 100 and 200”
- Expected output: “total should be 300”
That’s it.
Why do we test?
Because code breaks.
Even when we think it won’t.
You may change one line today, and something else breaks tomorrow.
A good test tells you immediately:
“Hey, the total is wrong now. Fix it.”
Testing is not for smart developers.
Testing is for busy developers who don’t want to re-check everything manually each time.
What is Jest?
Jest is a tool that runs your tests and tells you:
- ✅ if something works
- ❌ if something is broken
It’s like a teacher checking your answers.
But the difference is:
- Jest never gets tired
- Jest never forgets
- Jest checks everything in milliseconds
Our Example for the Entire Series
We will use one simple file throughout all 15 posts: an Expense Tracker.
Imagine we have a small function:
exports.getTotal = (list) => {
return list.reduce((a, b) => a + b, 0);
};This function adds all expenses.
A test for it might look like:
Input: [100, 200]
Expected Output: 300
That’s a test.
How Jest Helps
Without Jest:
You would open Node, run your code manually, log values, re-run, and keep checking.
With Jest:
You write the test once.
Jest checks it automatically every time you run:
npx jestIf something breaks next month, Jest will shout:
❌ “Expected 300 but got 0”
This saves you hours.
What You Will Learn in This Series
Over the next 15 posts, you will learn:
- How to write tests
- How to test errors
- How to test async functions
- How to mock APIs
- How to mock your own functions
- How to use fake timers
- How to test React Native logic
- How to use Jest with TypeScript
- And more…
All using the same Expense Tracker example.
✅ Summary
- A test checks if code works.
- Jest runs the tests for us.
- We will use a tiny expense tracker example for everything.
- You will understand testing from scratch, even if you’re a complete beginner.
💬 Comment what confused you most about testing — I’ll cover it in the next post.
Thanks for reading.
I explain things in simple words so learning stays easy today and even years later.
If this added value, follow me for more clear and practical posts.
— Alkesh Jethava