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:
or equivalent to run the tests as you normally would.
browserify your tests
To get your tests running in browsers, first install
npm install -g browserify),
$ browserify test.js > bundle.js
drop a script tag into a
test.html in your local browser. The test output will appear in your
using the testling command
For even more extra goodness, you can
npm install -g testling, then do:
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
The testling command parses the
package.json field the same way as
testling-ci, so it will look at the
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