Resolving popular mistakes in Angular JS unit testing (part 1 of many)
In this series of posts I will be sharing some common mistakes I’ve made and seen while unit testing Angular JS code. I mostly use Karma with Jasmine, and haven’t tried any of this with other testing frameworks.
Error #1: Unit testing a component controller with $componentController
Since Angular JS 1.5, we can use components instead of directives, and then we can test the component’s controller using $componentController instead of the $controller we used with directives.
Seems pretty much straight forward, however, some things may fail. Let’s see an example.
tl/dr: Please see Conclusion at the end.