Simultaneous Multiple-Browser JavaScript Testing With Yeti

Tweet

Developers detest tests. It’s tedious to verify code which is obviously perfect. To make matters worse, the humble web developer rarely knows what OS or browser a user will choose and must test a variety of platforms. The top 5 browsers may be relatively easy, but they’ve been joined by an increasing varied and powerful array of mobile devices.

JavaScript is particularly problematic. Developers are creating complex client-side applications and unit testing has become essential. There are a number of libraries which can help, including YUI Test, FireUnit and JsUnit. Unfortunately, it remains a largely manual process since only one browser can be tested at a time.

Yahoo’s YUI developers have some of the most stringent processes: they currently support 11 browser environments and test several emerging mobile platforms. Testing JavaScript functionality on one browser at a time was laborious and automated testing tools were complicated to configure and maintain.

To help ease the burden, Yahoo has released Yeti — The YUI Easy Testing Interface. It’s an open source project built on node.js which allows unit testing from the command line:


$ yeti mytestpage.html
✔ DOM Tests from Safari (Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) 
AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16)
  20 passed
  0 failed

However, it’s Yeti’s multi-browser capabilities that will excite most developers. Running Yeti without arguments starts a web server at http://localhost:8000/. Any browser can be pointed at that URL — including mobile devices if you use a system such as localtunnel to create a public address for the local server. Every test you then run is automatically executed on all browsers visiting the Yeti URL and the results are returned to the console. Amazing.

Yahoo admit Yeti’s not complete, but you can download the v0.1 code today. It’s only been tested on Mac OS X, although it may work on a Linux PC with node.js. Once it’s running, any browser running on any OS can be pointed at the server.

Yeti has the potential to make JavaScript unit testing far easier than it is today. It’s certainly a project we’ll watch with interest.

Related links:

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • (Paul McKeown)

    “Developers detest tests.”

    Not true! I love actually seeing what I have developed doing what I built it for. Sometimes it doesn’t, that can be frustrating, though…

  • http://www.brothercake.com/ brothercake

    Forgive me if this is a stupid question, but how exactly do you automate browser testing? How for example, do you automate a test in which the criterion is the layout of a widget, whether it has any rendering glitches, or even something simple like whether it appears in the right place?

    • http://www.optimalworks.net/ Craig Buckler

      Rather than visual layout checks, Yeti appears to be aimed at those doing unit tests, i.e. does function F return X when Y is passed.

      However, you could probably implement some sort of automated visual checking, e.g. checking the resulting height of content added to a box. It’s unlikely to be reliable in all situations, but it could alert you to potential visual issues.