local tests

If your test suite plays nicely with node-style modules and writes TAP output with console.log(), running your tests locally is super simple!

tape is a really simple test library you can use that plays very nicely with testling, but you could also use mocha or you can roll your own test library.

testing in node

If you're using tape or a similar TAP-producing library and your code works in both node and the browser, you can just:

$ node test.js

to run your tests! You get TAP output and a non-zero exit code when a test fails.

For mocha or other libraries that require a custom harness, just type:

$ mocha

or equivalent to run the tests as you normally would.

browserify your tests

To get your tests running in browsers, first install browserify (npm install -g browserify), then do:

$ browserify test.js > bundle.js

drop a script tag into a test.html file:

<script src="/bundle.js"></script>

then open test.html in your local browser. The test output will appear in your browser's debugger.


using the testling command

For even more extra goodness, you can npm install -g testling, then do:

$ testling

which will find and launch a real local browser on your system and copy the console.log() output from your tests to your terminal. It even gives you a non-zero exit code if there were errors!

You can launch a custom browser command with testling --bcmd=CMD or if you want to visit the urls manually you can just use testling -u to print the urls to visit.

The testling command parses the package.json field the same way as testling-ci, so it will look at the html, files, scripts, and harness fields in order to run your tests the same as on testling-ci.

testing individual files

If you want to run an individual test file and are using a test library that doesn't require a custom harness (like tape), you can do:

$ browserify test/somefile.js | testling

You can run multiple files this way too if you like:

$ browserify test/*.js | testling
quick start guide
Create a github hook to run your tests on every push. Get a browser badge.
writing tests with tape
Write tests with a minimal test api that works in both node and browsers.
testing locally
Run your tests in node and your local browsers.
writing tests with mocha
Run tests in mocha for qunit, tdd, bdd, and exports-style tests.
module-driven development
Write code that is easier to maintain and easier to test with browserify.
dependency management
Use npm to manage your front-end dependencies.
advanced configuration
Read in-depth about the package.json "testling" field.
custom test libraries
Use your own test library by outputting TAP with `console.log()`.