Writing unit tests
If you follow all the previous recommendations, then your code will be in a good position to be unit tested. The primary consideration while writing unit testable code is mockability: code whose external dependencies are loosely coupled. Loosely coupled dependencies can be replaced in a unit test with a fake, stub, mock, spy, or other form of replacement whose behavior can be controlled by the test. This challenge is solved by keeping DOM and binding the code out of your viewmodel, keeping the modules small and avoiding tight coupling to other viewmodels through practices such as dependency injection.
There are several frameworks that are available for unit testing in JavaScript, and they all offer similar benefits and workflows. The important thing is not what tools you use to unit test, only that you write unit tests. The value of unit testing really can't be overstated. It is even more important in dynamic languages such as JavaScript that do not offer compile-time checking...