A tape test runner that runs your tests in
a (headless) browser and returns 0/1 as exit code, so you can use it as your
npm test script.
First write a test utilizing tape and save
var test = ;;
Then run this command using tape-run and browserify and watch the magic happen as the TAP results stream in from a browser (default: electron):
$ browserify test/*.js | tape-runTAP version 13# oneok 1 true1..1# tests 1# pass 1# ok$ echo $?0
To use with webpack, simply include this plugin:
var run = ;var browserify = ;;
And run it:
$ node example/api.jsTAP version 13# oneok 1 true1..1# tests 1# pass 1# ok
opts can be:
wait (Number) [Default: 1000]: Make
tap-finishedwait longer for results. Increase this value if tests finish without all tests being run.
port (Number): If you specify a port it will wait for you to open a browser on
http://localhost:<port>and tests will be run there.
static (String): Serve static files from this directory.
browser (String): Browser to use. Defaults to
electron. Available if installed:
keepOpen(Boolean): Leave the browser open for debugging after running tests.
node(Boolean): Enable nodejs integration for electron.
basedir(String): Set this if you need to require node modules in
The CLI takes the same arguments, plus
--render (see blow):
$ tape-run --helpPipe a browserify stream into this.browserify [opts] [files] | tape-run [opts]Options:--wait Timeout
...or any of the other options you can pass to browser-run.
In order to apply custom transformations to tap output without sacrificing the proper exit code, pass
--render with a command like tap-spec:
$ browserify test.js | tape-run --render="tap-spec"one✔ true
To use tape-run with travis, we recommend using the default electron browser, which however requires you to add this part to your travis.yml:
addons:apt:packages:- xvfbinstall:- export DISPLAY=':99.0'- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &- npm install
For gnu/linux installations without a graphical environment:
$ sudo apt-get install xvfb # or equivalent$ export DISPLAY=':99.0'$ Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &$ browser-run ...
There is also an example docker machine here.
With npm do
$ npm install tape-run -g # for cli$ npm install tape-run # for api
Copyright (c) 2013 Julian Gruber <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.