Skip to main content

Simultaneous Multiple-Browser JavaScript Testing With Yeti

By Craig Buckler

JavaScript

Share:

Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

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:

Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.

New books out now!

Learn valuable skills with a practical introduction to Python programming!


Give yourself more options and write higher quality CSS with CSS Optimization Basics.