Live data from Hacker News

Ask HN: What do you use to test Frontend code?

news.ycombinator.com

1–10 of 47 posts

Ask HN: What do you use to test Frontend code?

#1
At our startup, we are trying to sort out the best way to handle testing against our supported Browser matrix. We want something that is repeatable and automated. We've looked into QUnit and Selenium but have this nagging feeling that we are doing it wrong.

Our application is primarily one page and uses a lot of jQuery to both animate things on screen and to work with the backend via AJAX.

Any hard won tips out there?

Re: Ask HN: What do you use to test Frontend code?

#5
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?

#6

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 s…

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?

#8
We use jsTestDriver at Picklive to test our game, alongside Sinon.js for a mock implementation of our game server. It's very easy to test simultaneously on multiple browsers, run tests on the command line, and we run it headless for continuous integration.

In comparison with Selenium, I've found unit and integration tests using this setup fast and resilient.

Re: Ask HN: What do you use to test Frontend code?

#10
post #6

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 s…

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.

Good point, I forgot that you could just use it standalone!
Post reply on HN