Handy utils for Angular unit testing
TADA is a set of smart spies that will make your unit tests more readable.
It was born after writing the same patterns again and again and after writing hundreds of bad looking / unreadble tests.
For more info checkout our slides or watch the video of the talk we gave at AngularJS IL.
- Your tests will look better and will be more readable.
- No more writing the same mocks over and over again.
- No more writing complicated async mocks using $q and adding ugly $disget() calls in the middle of your tests.
- Use our enhanced spies with the apis such as:
spy.whenCalledWithArgs(myArgs).returns(customResponse);
Download latest release from here or use bower (recommended)
bower install tada --save-dev
- Load tada.js in your favourite test runner (i.e karma):
// list of files / patterns to load in the browser
files: [
'app/bower_components/tada/dist/concat/scripts/tada.js',
]
- Create your app test kit file (recommended place is under specs/lib)
'use strict';
angular.module('myAppTestKit', ['tada'])
.service('myServiceMock', function (tadaUtils) {
this.asyncServiceMethod = tadaUtils.createAsyncFunc('async service method');
this.syncedMethod = tadaUtils.createFunc('service synced method');
})
.service('thirdPartyServiceMock', function (tadaUtils) {
this.doSomething = tadaUtils.createFunc('do something');
});
- Load the test kit module in your test and pick which dependencies you whould like to mock.
module('myAppTestKit', function (tadaUtilsProvider) {
tadaUtilsProvider.mock('thirdPartyService');
});
Cooming soon
You can checkout TADA showcase here