This is something I've been struggling with for a while, as I do some work with ExtJS (a very powerful JavaScript browser interface) and Rails.
After exploring several options. I still have not found the perfect solution for this. Ideally, I could run them headless and just report the exit. Unfortunately, none of the emulators there seem to be able to easily run JavaScript with full DOM support (at least not one of the options I found). Thus, to a large extent, this means that you need to run the full JavaScript code in a real interpreter (for example, in a browser). Webrat with Selenium works reasonably well, assuming you're ready to handle the pain by trying to properly handle your user interface requests. If this is your own JavaScript with which you implement it, it might be easier. But when it comes to a third-party user interface library, for which you do not have much control, it can certainly get, let's say, interesting.
This is probably not the most helpful answer, but these have been my results so far!
Christopher wj rueber
source share