npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

assert-called

0.1.2-1

@mmalecki

npmHomeRepoSnykSocket
Downloads:180
$ npm install assert-called
DailyWeeklyMonthlyYearly

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.