A unit is a small section of code. Unit testing means you test that bit of code to make sure it functions properly. This increases confidence in your code.
Unit tests are important when many people work on the same codebase. If one engineer changes code in one part of the project, you want to ensure that the rest of the project still works.
Unit tests are especially important in dynamically typed languages such as JavaScript, since there is no compiler to catch common problems.
Below are the some of the articles written by Matt how we can test the JavaScript code:
1) JavaScript unit testing: guiding principles and common excuses By Matt Harrington
2) How to write JavaScript unit tests with Mocha By Matt Harrington
3) JavaScript unit testing: using the Chutzpah test runner in Visual Studio By Matt Harrington
4) Using Mocha JS, Chai JS and Sinon JS to Test your Frontend JavaScript Code
Hope this will help !!!
Jay Ganesh