
Learning Vue.js 2
By :

Before we start writing unit tests, let's try to understand what we're trying to achieve by writing them. Why is unit testing so important? Sometimes when I write my tests, the only thing I can think about is my code coverage; I want to achieve a level of 100%.
Code coverage is a very important metric and helps a lot to understand the code flow and what needs to be tested. But it is not a metric of unit test quality. This is not a metric of a good code quality. You can have your code 100% covered just because you call all your functions in your testing code, but if your assertions are wrong, the code might be wrong as well. Writing good unit tests is an art that requires time and patience. But when your unit tests are good enough and when you are concentrating on making good assertions, with regard to corner cases and branch coverage, they provide the following: