Testing with Angular.js, Clojurescript and Purnam - Code and Part 1

271 views
Skip to first unread message

zcaudate

unread,
Nov 5, 2013, 5:31:42 AM11/5/13
to clo...@googlegroups.com

--------

Even with the karma test runner, testing in angularjs is painful. It's one thing to be able to write a angular.jscontroller, 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 and Here. 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

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.

The point I've been making on previous post 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 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.angularpurnam.test andpurnam.test.angular work together.



Josh Kamau

unread,
Nov 5, 2013, 5:39:38 AM11/5/13
to clo...@googlegroups.com
zcaudate, 
You realize you have posted on a clojure mailing list??


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Chris Zheng

unread,
Nov 5, 2013, 5:56:02 AM11/5/13
to clo...@googlegroups.com
I'm sorry ;-)

but I've written that many clojure macros for this library that i think the post is still relevant =)


You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/qbr4DRJp1SI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Mark Mandel

unread,
Nov 5, 2013, 6:55:44 AM11/5/13
to clo...@googlegroups.com
This is actually really relevant to me - I'm *just* about to start writing angular tests with purnam.test.angular.

Thanks!

Mark

zcaudate

unread,
Nov 6, 2013, 10:28:28 PM11/6/13
to clo...@googlegroups.com
I've since realised the other reason why I like posting on the clojure group....

- The clojurescript group for whatever reason does not take html format... it makes the post look super ugly.
Reply all
Reply to author
Forward
0 new messages