assert-called

0.1.2-1 • Public • Published

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:26
    throw new assert.AssertionError({
          ^
AssertionError: 1 callback not called:
  notCalled
    at Object.<anonymous> (/Users/maciej/dev/js/assert-called/examples/called-and-not-called.js:13:12)
    at Module._compile (module.js:454:26)
    at Object.Module._extensions..js (module.js:472:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:497:10)
    at process.startup.processNextTick.process._tickCallback (node.js:325:13)

How it works

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

Readme

Keywords

none

Package Sidebar

Install

npm i assert-called

Weekly Downloads

6

Version

0.1.2-1

License

MIT

Last publish

Collaborators

  • mmalecki