Automate TAP browser unit tests with WebDriver
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Build Status Dependency Status

Easily run TAP-producing JS unit tests in the browser, automated by WebDriver with Node.js. This is a helper module for wd-tap, this module sets up the test page and HTTP server for you (using serve-script).


The browser you are testing must have access to localhost, either running locally or through a tunnel.

var runner = require('wd-tap-runner'),
    wd = require('wd'),
    browserify = require('browserify');

var myCode = browserify().add('./test.js').bundle(),
    browser = wd.remote();

browser.init(function() {
    runner(src, browser, { port: 8000 }, function(err, results) {
        // results is parsed using tap-parser


runner(src, browser, [options], callback)

Runs the tests in the browser. The browser must have access to localhost, either run the browser locally or open a tunnel to the remote browser.

src may be a stream or string of JS code that contains the tests that will be run. The JS code may output TAP output to the web browser console using console.log(line). The test page automatically displays the console output in the document.

browser is the WebDriver browser (created by wd) that the tests will be run in.

options is an optional object that may include the following:

  • port: The port the HTTP server will use
  • timeout: The timeout for the tests (in seconds). See the wd-tap documentation.
  • serverTimeout: The timeout for HTTP connections to the server. Default 2000 (milliseconds).

callback will be called with either an error or the TAP test results, parsed using tap-parser. Note that the error will be null even if some tests failed; the results indicate what tests passed or failed.