News for hackers. Stuff that matters.
Re:Ask HN: What do you use to test Frontend code? by dbalatero on Saturday September 03, 2011 @11:08AM (#2957384)
If you're in the Ruby world, Capybara is a great addon to Cucumber and RSpec. It solves the animation problem by adding a timeout to wait for elements in the DOM. A step like this:

When I click the link that does a 4000ms animation I should see "#mydiv"

Capybara will wait for #mydiv to appear for some timeout period (30 seconds). If it appears before then, it keeps going.

This way you can have complex animation and still assert final state of the page. Capybara allows Selenium, headless WebKit, and other JS drivers. It's one line to swap.

If you aren't in the Ruby world, you might at least steal some ideas from that lib to make your Selenium tests better.

Also, you might drop the folks at Pivotal Tracker an email. They have a fat one-page JS-heavy product, and I bet you anything they automatically test it. They might have cool stuff to share.

Re:Ask HN: What do you use to test Frontend code? by schrieaj on Saturday September 03, 2011 @11:24AM (#2957404)
Capybara works pretty well for any web based front end. I'm using it to do some basic automation of websites (scheduling tasks and the like). You write the tests in ruby but honestly it is really simple: http://pastie.org/2476405 is my script for logging in to google voice and sending a text message. If I recall it was simply gem install capybara, a gem install selenium-webdriver and that was it.
Re:Ask HN: What do you use to test Frontend code? by dbalatero on Saturday September 03, 2011 @12:21PM (#2957536)
Good point, I forgot that you could just use it standalone!