2

Can JSTestDriver be used to test DOM behaviors and interactions?

I see I can write tests to exercise pure JS but how do I go about testing against HTML or DOM?

Can I deliver with each test HTML for browsers to render and the tests to run against?

Zachary K
10.4k2 gold badges39 silver badges55 bronze badges
asked Feb 3, 2011 at 14:54
1
  • I always found JSTestDriver quite inconvenient when it comes to test JavaScript constructs that slightly interact with the DOM. I switched to QUnit in that case. Commented Mar 19, 2012 at 14:50

2 Answers 2

0

Try using the Html Doc feature...

You should be able to do stuff like:

 /*:DOC += 
 <div id="page">
 <div id="foo">yyy</div>
 <div class="bar">
 <p>xxxx</p>
 </div>
 <div>hilo!</div>
 </div>
 */ 

...inside your tests, and JSTestDriver will inject that stuff into the DOM. Of course, if you're talking about injecting entire complete pages into your test, this might not be that great an option. Having said that, testing your code against small pieces of DOM like this is probably going to give you better isolation.

answered Mar 10, 2011 at 19:28
1

I tend to use selenium. It lets you drive a browser and interact with the page. It can be quite useful for this kind of testing.

It does have some limits, You can do a lot of does element exist, if so click it. But its not so easy to check if it is visible, and not off screen or buried or the like

answered Mar 9, 2011 at 8:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.