Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including browserify-tape-spec with all npm packages installed. Try it out:

var browserifyTapeSpec = require("browserify-tape-spec")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

browserify-tape-spec v1.1.3

Browser reporter for tape stream.

browserify-tape-spec

Spec style reporter for your tape test output in the browser.

install

npm install browserify-tape-spec --save-dev

usage

In your markup you'll need an element to stream output to. In this example I have a <div id=out> for that purpose:

<html>
<body>
  <div id=out></div>
  <script src=bundle.js></script>
</body>
</html>

In the js we grab a reference to the reporter, invoke it with the element id we wish to stream the results to, and pass the resulting function to tape's pipe.

var test = require('tape')
  , report = require('browserify-tape-spec')

test('useful assertion description', function(t) {
  t.plan(2)
  t.ok('a passing test')
  t.fail('this test will fail')
  t.end()
})

test.createStream().pipe(report('out'))

Thats it! You can see a live example here.

contribute

A few ideas I haven't done just yet (and would love your help).

  • Scope the css to the passed in element
  • Mobile web friendly (viewport inject) the output
  • Output for comments/plan/todo

inspired by

  • https://github.com/substack/tap-parser
  • https://github.com/scottcorgan/tap-spec
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free