包详细信息

assert-called

mmalecki227MIT0.1.2-1

Assert that your callback got called

自述文件

assert-called Build Status

Assert that your callback got called.

Installation

npm install assert-called

Usage

var cb = require('assert-called');

function notCalling(cb) {
}

function notCalled() {
}

process.nextTick(cb(function () {
  console.log('called');
}));

notCalling(cb(notCalled));

Will output:

called

/Users/maciej/dev/js/assert-called/lib/assert-called.js:20
    throw new assert.AssertionError({
          ^
AssertionError: 1 callback not called:
  notCalled

How it works

assert-called attaches a process.on('exit') listener to make sure that all registered callbacks are eventually called.