assert2

Node.js's assert plus 'emits' and 'doesNotEmit'

npm install assert2
6 downloads in the last month

Extends Node.js's assert with two new tests for events:

var assert = require('assert2'),
    events = require('events'),
    emitter = new events.EventEmitter();

assert.emits(emitter, 'event', function () {
    emitter.emit('event');
});

assert.doesNotEmit(emitter, 'event', function () {
    // zero-emissions code
});

SemVer compliant

API

All of Node's assert tests, plus:

assert.emits(emitter, event, block, [message])

Expects emitter to emit event while executing block. If untrue, throws an exception with a default message which you may override with message.

assert.doesNotEmit(emitter, event, block, [message])

Expects emitter not to emit event while executing block. If untrue, throws an exception with a default message which you may override with message.

License

MIT

npm loves you