Code:  https://github.com/zcaudate/purnam-angular-example
Demo: http://docs.caudate.me/purnam-angular-example/
Article: http://z.caudate.me/purnam-angular-js-testing-part-1-services/

--------

Even with the karma <http://karma-runner.github.io/> test runner, testing 
in angularjs is painful. It's one thing to be able to write a 
*angular.js*controller, 
its another to be able to test them. Making it more difficult is the sheer 
complexity of the framework. There are different strategies of testing 
controllers, directives, filters and injectables (values, services, 
factories and providers)

There are two excellent articles about testing in angular.js by Year of 
Moo. 
Here<http://www.yearofmoo.com/2013/09/advanced-testing-and-debugging-in-angularjs.html>
 and 
Here<http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-karma.html>.
 
However, my eyes start hurting when I look at the test code. It is modular, 
it is brilliantly thought out, it is *very* complete... but it is seriously 
hard to get my head around. An example of controller testing can be found 
here<https://github.com/yearofmoo-articles/AngularJS-Testing-Article/blob/master/test/unit/controllers/controllersSpec.js>

It took me about a couple of days to summon up the courage to even attempt 
to read the code. Then I realised that the tests weren't doing that much at 
all. Most of it was boilerplate and not that interesting. Out of about 5 
lines of test code, something interesting only happened in one of them. I 
abstracted out all the angular.js testing code into 
macros<https://github.com/zcaudate/purnam/wiki/Api---purnam-test-angular>
.

The point I've been making on previous 
post<http://z.caudate.me/if-you-cant-beat-them/> is 
that clojurescript rocks if we really embrace javascript libraries through 
macros. With macros for *angular.js*, working with angular.js is so much 
clearer than in javascript.

I have put together an example 
project<https://github.com/zcaudate/purnam-angular-example> that 
shows how one may go about doing a simple app with tests. I'm going to take 
a couple of posts to explain how purnam.angular, purnam.test and
purnam.test.angular work together.


-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to