Nocturnal Pumpkin Maelstrom
Miss any of our Open RFC calls?Watch the recordings here! »

tapeling

2.0.4 • Public • Published

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

Install

npm i tapeling

DownloadsWeekly Downloads

33

Version

2.0.4

License

ISC

Unpacked Size

10.5 kB

Total Files

7

Last publish

Collaborators

  • avatar