hoodwink

A dead simple mock/stub module for Javascript

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
hoodwink
002.0.04 years ago5 years agoMinified + gzip package size for hoodwink in KB

Readme

hoodwink
build status Version
A dead simple mock/stub module for Javascript
TODO: hoodwink/async

Examples

const tape = require('tape')
const hoodwink = require('hoodwink')

tape('stub returns 0, then 1', hoodwink(function (t) {
  const foo = this.stub(function f () {
    if (foo.calls === 0) return 0
    if (foo.calls === 1) return 1
  }, 2)

  t.equal(foo(), 0)
  t.equal(foo(), 1)
  // t.equal(foo(), ...) // XXX: throws! (as foo.calls would be > 2)
})
Protip: use function (...) {}, not () => {}, to prevent this binding issues

License MIT