write tests for browser code. bcmd, x option modified for browser-launcher2. Modification of original testling by @substack
Last updated 3 years ago by sergueyarellano .
MIT/X11 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install testling-bl2 
SYNC missed versions from official npm registry.


Run testling-ci tests locally.


write a test:

var test = require('tape');

test('beep boop', function (t) {
    t.equal(1+1, 2);

run your test in a local headless browser:

$ browserify example/test.js | testling

TAP version 13
# beep boop
ok 1 should be equal
ok 2 (unnamed assert)

# tests 2
# pass  2

# ok

with an exit code of 0 for successes and non-zero for failures like a good unix citizen

Once you have a package.json with a configured "testling" field, you can just type:

$ testling

to run all your tests locally just like they will be run on testling-ci. This includes mocha harnesses, scripts, and files parameters.


usage: testling {DIRECTORY|-} {OPTIONS}

If there (is no DIRECTORY and stdin is a tty) or the DIRECTORY is "-",
javascript will be read from stdin and executed.

Otherwise, DIRECTORY (or the $CWD) will be checked for a package.json with a
testling field.


     --html  Instead of launching a server, show the generated html.

  --no-show  Don't render the console.log() output to the document body.

         -u  Instead of launching a browser, print the url to visit so you can
             open the browser yourself.

         -x  Launch a browser available in your system ($PATH is not required).
             Choose between firefox, chrome, safari, ie, phantomjs, opera

testling field

Read more about how the package.json "testling" field works.

code coverage

To compute code coverage, just use the coverify transform with -t coverify when you run browserify.

coverify writes coverage data with console.log(), so you can pipe the output of testling through to the coverify command to parse the results and give human-readable output:

$ browserify -t coverify test.js | testling | coverify

TAP version 13
# beep boop
ok 1 should be equal

# tests 1
# pass  1

# ok

# /home/substack/projects/coverify/example/test.js: line 7, column 16-28

  if (err) deadCode();

# /home/substack/projects/coverify/example/foo.js: line 3, column 35-48

  if (i++ === 10 || (false && neverFires())) {

The exit code of coverify is non-zero when there are unreachable expressions.


First, install browserify globally so that the testling command can find it when there is no browserify in ./node_modules/.bin:

npm install -g browserify

then do:

npm install -g testling



attack of the testlings!

Current Tags

  • 1.7.4                                ...           latest (3 years ago)

3 Versions

  • 1.7.4                                ...           3 years ago
  • 1.7.3                                ...           3 years ago
  • 1.7.2                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 0
Dependencies (17)
Dev Dependencies (1)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |