If you are unfamiliar with the concepts of TDD (test-driven-development) there's a vast sea of information about it. Just use your favourite search engine and jump in.
The concept it self is very simple. First write you tests then write code that will be tested.
In reality this is hard. It's hard because is like thinking backwards. It's hard because you might not always now what something need to do or how the specific API works. You need to experiment first. Do not fear, TDD and unit testing will help you. One of the most important things to know is that TDD is not a ruleset, it's a tool. And you'll soon find that your code is more decoupled and more awesome.
Before running your tests you need somewhere to run the tests. Here Karma is your friend. Karma is easily installed with npm: