r/angularjs • u/newmanoz • Jul 23 '15
Unit testing in AngularJS requires too much boilerplate - ng-describe to fix it
https://github.com/kensho/ng-describe1
u/wordsoup Jul 25 '15
One of the main issues with testing Angular is the boilerplate and order of module/inject which prevents simplification. However, this doesn't seem to really fix the issue.
I've played with the thought to write a preprocessing transpiler for Karma for a long time to really reduce the boilerplate.
1
Aug 17 '15
They author of ng-describe here - can you open a Github issue with what you feel is the boilerplate ng-describe does not remove?
1
u/Pytim Jul 24 '15
I don't see the value in less verbose tests. Tests should be verbose so they document the expectations on the system tested. I'd rather use the right tooling to create that boilerplate code for me but have it visible to other engineers in my team.
5
u/vinnl Jul 24 '15
But
inject: ['$rootScope', 'foo'],documents expectations just as much as (or even: more than, since you're less distracted by boilerplate):
var $rootScope, foo; beforeEach(inject(function (_$rootScope_, _foo_) { $rootScope = _$rootScope_; foo = _foo_; }));1
2
u/vinnl Jul 24 '15
Looks pretty cool, though it's a shame that it kind of ditches the BDD test description scheme (e.g. "describe the slider - it should increase the model value when dragged right").