[LRUG] Testing JS in Rails 4

Murray Steele murray.steele at gmail.com
Wed Jul 31 03:34:09 PDT 2013


Could you customise the digest mechanism in sprockets to produce empty (or
knowable) digest suffixes.  Of course, you'd only want this for the JS test
run, so you're not testing your exact production files, but you're testing
something very close to it.

Alternatively, could you asset compile the JS test harness so that it has
the digested asset names in it?


On 30 July 2013 20:14, James Coglan <jcoglan at gmail.com> wrote:

> I have a conundrum. Whereas:
>
> * JS testing is easiest if done with a bunch of static HTML/JS files
> rather than booting a web framework and various weird opaque and brittle
> glue libraries, especially if you want to use a runner/CI system like
> TestSwarm, Testling, Karma, Testem or Buster
>
> * Testing your production files is better than testing your source code
>
> * The Rails 3 asset pipeline produced files both with and without digest
> hashes in the filename, and you could use the predictable digest-less names
> for test setup (even though compiling assets in development mode produces
> other weird bugs because of Heroku using ActionDispatch::Static in
> production)
>
> * The Rails 4 asset pipeline no longer produces digest-less files
>
> Therefore:
>
> How do you test your JS? My opinion so far is to just write source JS that
> doesn't require a build step, or use a build system that's not coupled to
> Rails.
>
> Your thoughts?
>
> --
> James Coglan
> http://jcoglan.com
> +44 (0) 7771512510
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130731/3b91293d/attachment-0003.html>


More information about the Chat mailing list