node-mock-fun
Mock functions
Install
npm install mock-fun
Usage
Use with mocha :3
.override(obj, prop[, glob])
Without glob
function:
Returns a hook(fun)
function, that can override prop
in obj
with a wrapper function that calls fun
transparently
(keeping context¶meters). The wrapper function manages the
called
and calledTimes
property.
fun
defaults to noop.
With glob
:
Returns a hook
function that overrides prop
in obj
with a wrapper function that calls glob
transparently. Same as above.
You should use this as a before/beforeEach
hook.
.restore(obj, prop[, full])
Returns a hook
function that restores the original function.
You should use it as an after/afterEach
hook.
Set full
to restore nested overrides.
Example
var override = override;var restore = restore; // Override per `it`; // Override per `describe`;
License
MIT