mck
v1.1.1
Published
A mocking library for node
Downloads
23
Readme
mck
Basic mocking library.
Installation
npm install mck
Dependencies
None
Usage
var mock = require('mck')
mock.once(console, 'log', function(msg) {
process.stdout.write('hello ')
})
console.log('goodbye')
console.log('world')
// hello world
var mock = require('mck')
var sqrt = mock(Math, 'sqrt', function() {
return 42
})
console.log(Math.sqrt(42))
// The real Math.sqrt
console.log(typeof sqrt.real)
// function
console.log(sqrt.invokes)
// 1
sqrt.restore()
console.log(Math.sqrt(1764))
// 42
Author
Andreas Brekken <[email protected]>
Alternatives
License
MIT