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

var assert2 = require("assert2")

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

assert2 v0.1.0

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

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

Metadata

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