ngImprovedTesting: mock testing for AngularJS made easy
Being able to easily test your application is one of the most powerful features that AngularJS offers. All the services, controllers, filters even directives you develop can be fully (unit) tested. However the learning curve for writing (proper) unit tests tends to be quite steep. This is mainly because AngularJS doesn’t really offer any high level API’s to ease the unit testing.
Integrating Karma (Testacular) test runner in WebStorm 6 / IDEA 12
NOTE: version 7 of WebStorm already comes with built-in Karma support.
However IntelliJ IDEA 12 users will have to wait for v. 13, making this article still relevant for them.
Easy installation of Karma (Testacular) test runner on Windows
NOTE: this post was written for Karma 0.8 which required a manual installation of PhantomJS.
However this blog post is still relevant for installing the NodeJS and NPM pre-requisites.
As of 0.10 both PhantomJS and Chrome will be automatically installed by the launcher plugins.
Installation instructions for Karma 0.10 can be found here (a “Local installation” is preferred).
Furthermore instructions on how to install plugins (introduced as of 0.10) can be found here.
How to create (singleton) AngularJS services in 4 different ways
Next to creating controllers and directives, AngularJS also supports “singleton” services. Services, like on the server-side, offer a great way for separating logic from your controllers. In AngularJS anything that’s either a primitive type, function or object can be a service. Although the concept of service is quite straight forward, the declaration of them in AngularJS isn’t:
Safe-guarding AngularJS scopes with ECMAScript 5 "Strict Mode"
Adding custom HTML attributes to your AngularJS web app
- “ngView”: defines the placeholder for rending views
- “ngModel”: binds scope properties to “input”, “select” and “text” elements
- “ngShow” / “ngDisabled”: for showing or disabling an element based on the result of an expressions