Today, the cool kids at LearnBoost Labs, the creators of a pretty sweet online gradebook service, released Soda, a web testing library for NodeJS and Selenium, with built-in integration for cross-browser testing with Sauce Labs. It's truly awesome. (It's earned an exception to my general rule against the over-use of the word 'awesome'.) Node.js is the new kid in web technologies, but it's experiencing rapid growth in developer adoption, at a rate not seen since the early rise of Rails. Here's a sample acceptance test written with soda:
var soda = require('soda'); var browser = soda.createSauceClient({ 'url': 'http://yourwebsite/' , 'username': '' , 'access-key': '' , 'os': 'Windows 2003' , 'browser': 'googlechrome' , 'max-duration': 300 }); browser .chain .session() .setTimeout(5000) .open('/') .waitForElementPresent('username') .type('username', 'invalid') .type('password', 'invalid') .click('//input[@value="Submit"]') .waitForElementPresent('css=ul.global-errors') .assertText('css=ul.global-errors li', 'Please check your username / password') .testComplete() .end(function(err){ if (err) throw err; console.log('Passed!'); });
Using chained methods, Soda very elegantly solves Node's "ugly callback syntax" problem. I suspect more NodeJS libraries will copy this pattern. Seriously, check out Soda now! :-)