Testing Angular Directives with Karma, Mocha, and Phantom
All Code on Github The entire code from this article is on github . Introduction Angular Directives are part of the web part/components group of client-side tools that allow quick additions to web pages. The idea is that with a very simple and short addition to an html page, complex functionality and UX are available. Imagine a user login form with the traditional validation contained in a html template and Angular controller. The main, calling web page’s html could just include <login></login> to bring in that rich validation and display. Directives are wonderful for encapsulating the complexity away from the containing HTML. Testing the directive is trickier. Granted the controller isn’t difficult to test. But the compiled html and scope are not so easy. Perhaps it is enough to test the controller, and depend on the browser and the Angular library to manage the rest. You could definitely make that case. Or perhaps you leave the compiled directive ...