trevmex's tumblings

JavaScripter, Rubyist, Functional Programmer, Agile Practitioner.

Ruby DCamp 2010 Session 1: JavaScript Testing

Evan Light, et. al.

SauceLabs - an HTML/JavaScript testing tool. This is a paid service ($5000/10,000 browser tests), but they save all the results and give you detailed reports.

HolyGrail - You can use this to hook into the DOM through Ruby, but it is not 100%. It is good for simple AJAX stuff, but might not be the best for the more advanced features.

  • The dream that is the HolyGrail is a full stack (from front-end to back-end) testing suite
  • It needs helper functions (i.e., it needs a nicer API).
  • It uses Johnson, which is Ruby wrapped in SpiderMonkey, running on top of ENV JS.
  • This would be a great project to pursue for improvement.

ENV JS - A user-agent written in JavaScript. This can be useful for testing without a browser.

Capybara is very popular with this crowd.

HTML Unit is a pretty young library, but has some potential. ENV JS, might be a better solution.

Front-end testing is important for developers, but can be useful for QA as well.

You cannot do serious refactoring without unit tests

Jasmine, from PivotalLabs - a mature RSpec-derived JavaScript unit testing script. It runs very fast, but might be hard to setup.

  • There is a Jasmine add-on called Evergreen that adds some nice features to Jasmine, but it is not quite ready for prime time.
  • Jasmine has 2 modes: you can run the tests through your html, OR you can have RSpec generate your html pages on the fly.
  • The cool part is that you can test by changing yours code, and just refreshing your browser.
  • Jasmine runs in the browser by default, but you can run it headless using ENV JS.
  • Evergreen makes setting up Jasmine a LOT easier.

You can avoid integration testing (using things like selenium) at your own risk (i.e., this is a bad idea), but these tools are more useful for unit testing your JavaScript.

TestSwarm: A website that helps you parallelize your test suite across many browsers.

The selenium-client gem gives you access to a more robust toolset than creating point and click tests using the Selenium IDE. It is recommended to use the gem for a more robust testing experience.

  • You can still use Selenium IDE to capture the basics of a test, and then refine the test with the selenum-client gem
  • Capybara can do all the same things as selenium-client, and is browser-agnostic, whereas Selenium IDE is only for Firefox (although the selenium-client is agnostic as well)

Hudson - this is a useful group/tool for continuous integration

Should there be a Ruby testing blog? (we are agreed that this is a good idea)

Fitness, by Uncle Bob, is picking up speed again for managing test reporting using a web interface.

What is the ideal testing environment? Something that is exactly like a browser, but headless, and faster than a browser.

  • rendering the DOM takes up a lot of time, having a headless solution should speed up testing.
  • one issue with a headless solution is that you might miss events that trigger while moving to from one place to another (e.g. mouseover events when moving your mouse from one element to another on the screen, which might be unintentional)
  • HolyGrail is kind of close to this.

Testerfield is another tool that is emerging that combines many different testing tools together.