My Rails application has almost as much (and maybe more) JavaScript as
it does Ruby code, and I'm wondering what the best option is for
testing it. Has any consensus developed regarding the best way of
testing JavaScript code in a Rails application? How are people
testing JavaScript in their own applications?
I’ve built another plugin around this concept, but using jsUnit instead and added code generators to make it easier to build up Javascript code source and test trees. I haven’t released anything yet (both me just not doing it and need to make sure I’m not breaking any licensing of the original javascript_test).
Send me an email if you want to check out what I’ve done and I’ll send you the code. One of these days I’ll clean up the plugin and release it officially.
My Rails application has almost as much (and maybe more) JavaScript as
it does Ruby code, and I'm wondering what the best option is for
testing it. Has any consensus developed regarding the best way of
testing JavaScript code in a Rails application? How are people
testing JavaScript in their own applications?
I test the JS one-liners that appear inside HTML attributes (such as
onclick) using assert_javascript.
This has the benefit of being a true unit test, without the overhead
of invoking a web browser against its optimization profiles.