JavaScript Unit Testing with TDD, Jasmine and Karma

JavaScript Unit Testing with TDD, Jasmine and Karma

In this article, we’ll introduce you to a tool combination which will make JavaScript unit testing so much easier. Jasmine and Karma combined will save you hours of testing.

First, let’s understand what exactly are TDD, Jasmine and Karma.

Test driven development (TDD) is one of the main, agile development techniques. The genius of TDD lies in writing your test’s code first, so it can guide your further implementations. This method provides you with an increased quality of code, improved bug detection and overall faster development. The bigger and more important the system you’re building, the more helpful these techniques will be:

  1. Write your test first, and see it fail. (Red)
  2. Write your unit of code and see the test pass. (Green)
  3. Make your code better, using the tests to keep you safe. (Refactor)

Continue reading