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 1,000,000+ packages pre-installed, including tapeling with all npm packages installed. Try it out:

var tapeling = require("tapeling")

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

tapeling v2.0.4

Helps produce TAP reports

about

Helps gather TAP reports. Combines with likewise in tapeless for Node.js or browser side testing.

setup

Download the latest stable version from the npm registry:

# Add to 'package.json' development dependencies
npm install tapeling --save-dev

usage

Assuming a test function that throws if a given operation fails as for example,

// Check for sameness or equality
function throwsIfDifferent(a, b, message = 'Sorry!') {
  const result = Object.is(a, b)

  if (!result) {
    const error = Error(message)

    error.operator = 'is'
    error.expected = a
    error.actual = b

    throw error
  }

  return result
}

Wrap with tape() and call exit() to print out the corresponding TAP report. For example,

const { tape, exit } = require('tapeling')

const test = throwsIfDifferent
const assert = tape(test)

assert
  // Fails
  .test(2, 3)
  // Name test case, add diagnostic
  .describe('is same', 'will compute')
  // Passes
  .test(2, 2)

// Print totals
process.on('exit', exit)

Sample output with truncated error stack:

TAP version 13
not ok 1 - throwsIfDifferent
  ---
  operator: "is"
  expected: 2
  actual: 3
  stack:
    Error: Sorry!
        at throwsIfDifferent
  ...
ok 2 - is same
# will compute

1..2
# tests 2
# pass  1
# fail  1

see also

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