testium (GitHub: groupon/testium, License: BSD 3-Clause) is a testing platform focused on providing a simple, but effective, platform for testing your code in different browsers (via Selenium) and headlessly (via PhantomJS). It uses which Groupon wrote in order to communicate using the WebDriver protocol to a Selenium server.
npm install testium
@Groupon‘s Browser Integration Testing platform #Testium is now open source! #nodejs + Mocha + Selenium = Happy! https://t.co/lgXiRjflx0
— Jess Telford (@jesstelford) December 18, 2013
From the introductory article:
We wanted to write tests in JavaScript and Mocha with a synchronous API that takes advantage of our existing Selenium infrastructure. WD.js came close, but the challenge for full adoption came with the syntax, which is callback-based or promise-based. These are typical patterns in JavaScript projects, but for an integration testing tool, we only want to execute serial actions. A synchronous API made the most sense.
and
Further, there are existing technical limitations due to WebDriver being a common standard across all browsers. Some aspects can’t be implemented in a specific browser and therefore these features are not implemented at all.
There are four specific issues with WebDriver we wanted to resolve:
- response status codes unavailable
- response headers unavailable
- request headers not modifiable
- page must be loaded to set cookies
Example
A simple test using .
{getBrowser} = require 'testium'
assert = require 'assertive' # or whatever assert library you prefer
describe 'browse', ->
before ->
@browser = getBrowser()
@browser.navigateTo '/my-account'
assert.equal 200, @browser.getStatusCode()
it 'is serving up gzipped content', ->
assert.equal 'gzip', @browser.getHeader('Content-Encoding')
More
One of the more exciting and unique features is ability to diff screenshots and fail based on the difference. This isn’t a new idea, but shipping it as part of a testing framework can increase its adopatation. Finally, check out the demo video and don’t forget to read the introductory article.
On the side note, super excited to find out that Groupon is using CoffeeScript! Are you?