Went through few articles about Javascript testing and came to know Enzym, Jest, Karma, Mocha these all are the popular testing tools. But nobody has mentioned what is the real purpose of Unit testing, Integration testing. Expecting the relevant replies.
Thank you!
Unit and integration/feature testing can check if a part of your app has broken (one more specifically than the other). E2E testing check if your code breaks on the client-side (when the app is actually used).
With React components for example, it's important to not only unit test your functions and classes that compose your components, but also alter the state and integrate other components to see how the app behaves.
Vishwa Bhat
Technology Enthusiast
Vishwa Bhat
Technology Enthusiast
--- Scene 1: Without writing unit tests ---
You: Phew! Finally my code is handling all the scenarios! commits the code
After few days...
Teammate: Hey bro, I want to introduce couple of changes in your code, I just want one use-case to handle in my task.
You: No Problem at all !
Teammate makes blunt changes in your code and the build is deployed and now your code started breaking in production on weekend...
You might argue that you didn't even touch the code for this release yet it happened. You spend hours figuring out why it happened. Suddenly you notice that the code change introduced by your teammate is the causing one of your use-cases to fail . There'll be some blame game between you two and blah blah, then you'll try to understand the context and after a day or two, the issue finally gets resolved.
--- End of Scene 1 ---
--- Scene 2: With writing unit tests ---
... ...
Teammate: Hey bro, I want to introduce couple of changes in your code, I just want one use-case to handle in my task.
You: No Problem at all !
After a while..
You: Hey, could you introduce the changes in my code?
Teammate: No bro, my changes are breaking tests, I'll introduce my changes carefully and write unit-tests for my changes too so that it won't break in future.
He'll introduce appropriate changes and the build process will be triggered. All tests will pass. Everyone will enjoy their great weekend
---End of Scene 2---
It can be your teammate or yourself who might introduce the flaw in the code. Unit tests will come really handy to detect functionality loopholes in your code way before the code is even deployed.
I hope I clarified your question.
P.S. Please excuse my informal way of answering the question. I was bored.