For testing libraries that want to use an existing assertion library like the awesome power-assert
, but collect all the results up without letting failed tests throw errors.
Usage
const noThrow = require('assert-no-throw')
const rawAssert = require('power-assert')
const assertWrapper = noThrow(rawAssert)
assertWrapper.assert.deepEqual({ thing: 'thingy' }, { thing: 'thingy' })
assertWrapper.assert.deepEqual({ thing: 'thingy' }, { thing: 'WAT' })
assertWrapper.results
Result objects
Have these properties:
method
: string, the name of the assertion methodpass
: boolean, whether the assertion method threw an error or noterror
: if pass
is false, this should be an Error
instance
Events
The assert wrapper object is an event emitter - it emits just one event, assert
, whenever a method is called. The event contains an object matching the result object above.
License
WTFPL