Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

tapeless

1.0.3 • Public • Published

about

A tape inspired test harness to combine the Node.js built-in assert module with likewise on the browser side using the tapeling TAP reporter.

setup

Download the latest stable version from the npm registry:

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

usage

In Node.js all of assert is wrapped a-la tapjs/tapsert making a range of involved checks available. For example,

const { deepStrictEqual, equal, doesNotThrow, ok } = require('tapeless')
const sample = { a: 'a', b: 'b' }
const id = (input = sample) => input
 
equal.test(typeof id, 'function')
doesNotThrow.test(id)
ok.test(sample)
deepStrictEqual.test(sample, id())

Giving TAP results of:

TAP version 13
ok 1 - equal
ok 2 - doesNotThrow
ok 3 - ok
ok 4 - deepStrictEqual
 
1..4
# tests 4
# pass  4

Assertions provided on the browser side include just the basics ok() and equal() plus counterparts. Add kpow and cutaway to generate HTML formatted TAP output. For example, given a test script like:

// Sample test.js
import 'cutaway'
import { report, assert } from 'tapeless/browser'
 
const { equal: same, ok } = assert
 
const sample = { a: 'a', b: 'b' }
const id = (input = sample) => input
 
same.test(typeof id, 'function')
ok.test(sample)
same.test(sample, id())
 
report()

Bundling along the lines of:

npx -p kpow -p rollup -p @rollup/plugin-node-resolve -c \
'rollup -p node-resolve -f iife test.js | kpow'

Results in the following HTML report:

TAP in HTML sample

see also

Install

npm i tapeless

DownloadsWeekly Downloads

6

Version

1.0.3

License

ISC

Unpacked Size

8.71 kB

Total Files

11

Last publish

Collaborators

  • avatar