A unit test is an automated piece of code that invokes a unit of work in the system and then checks a single assumption about the behavior of that unit of work.
Angular is written with testability in mind, but it still requires that you do the right thing. We tried to make the right thing easy, but if you ignore these guidelines you may end up with an untestable application.
Angular comes with dependency injection built-in, which makes testing components much easier, because you can pass in a component's dependencies and stub or mock them as you wish.
Tool | Description |
---|---|
Karma | Test runner |
Jasmine / Mocha / UnitJS | Unit test frameworks |
I tried every test framework listed above and I definitely agree with the JS guy
- Full-Spectrum Testing with AngularJS and Karma (yearofmoo)
- Unit Testing Best Practices in AngularJS (Andy Shora)
- AngularJS Unit Testing Best Practices (Manuel Weiss)
- [:star:] Testing Promises with Jasmine (Bluescreen)
- Advanced Testing and Debugging in AngularJS (yearofmoo)
- Testing Services, Controllers & Providers (Rabi Kiran )
- [:star:] How to Unit Test an AngularJS Controller (Bradley Braithwaite)
- AngularJS Unit Testing – For Real, Though (Ben Lewis)
- Unit Testing AngularJS Modules (Edwin Guzman)
- How to Unit Test with real $http calls using ngMockE2E (Bradley Braithwaite)
- [:star:] JavaScript TDD with Jasmine and Karma (Christopher Bartling)
- TDD Basics with Angular.js and Jasmine (Luis Sánchez Castellanos)
- Testing JavaScript with Jasmine (Tim Tyrrell)
- Testing a controller with Jasmine
- Testing a directive with Jasmine
- Testing a filter with Jasmine
- Testing promises with Jasmine
- AngularJS Test driven Development (Tim Chaplin)
- [:star:] AngularJS Testing Cookbook (Simon Bailey)
- JavaScript Testing with Jasmine (Evan Hahn)