Can I unit test the DOM?

We have a Ruby on Rails application that uses some javascript in views. Since we have good testing coverage in the rest of the application, we want to continue this here. The js we use manipulate the DOM to show / hide divs and perform an incremental search for combobox choices from the table.

Does anyone know how to test DOM manipulation?

Franc

+3
source share
6 answers

You can use the HttpUnit or HtmlUnit java libraries, which can test the complete DOM after JS manipulation.

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

JavaScript Mozilla Rhino, DOM.

- .

: Ruby JRuby.

+3

jQuery , dom. QUnit.

+2
0

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

0
source

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

0
source

Source: https://habr.com/ru/post/1699674/


All Articles