3

We have a Ruby on Rails app that uses some javascript in the views. Since we have good test coverage on the rest of the app, we want to continue that here. The js we use manipulates the DOM to show/hide divs and perform incremental searching for a combobox selecting from a table.

Does anyone know of ways to test DOM manipulation?

Frank

1

6 Answers 6

3

You can use the java libraries HttpUnit or HtmlUnit that can test the finished DOM after being manipulated by JS.

http://htmlunit.sourceforge.net/javascript-howto.html http://httpunit.sourceforge.net/doc/cookbook.html

Both use the full-featured JavaScript engine Mozilla Rhino, and then add their own DOM implementations.

This will allow you to run these test automatically in the background without any browser or sideeffects.

Bonus: You can use call these libraries directly from Ruby using JRuby.

2

jQuery library ships with a pretty good unit testing library you can use to test dom manipulation. The library's called QUnit.

1

You could use YUI Test or Selenium.

0

I just answered a similar question. In short: take a look at Dojo's DOH, doh.robot and dijit.robotx (using Dojo is not required for DOH, and it doesn't depend on Dojo).

0

In the past I've done this with jsUnit.

0

Use capybara https://github.com/jnicklas/capybara with a JS enabled driver such as capybara-webkit or poltergeist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.