1.0.1 • Published 9 years ago

forget v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

forget

Simple dependency mocking for commonjs. Works in most cases for Node, browserify, and webpack.

Installation

npm install forget

Usage

Suppose you have a module that uses jquery.ajax and want to mock out that functionality:

//module.js
var $ = require('jquery')
$.ajax({
//...
})

Then in your unit tests:

//moduleSpec.js
var forget = require('forget')
var fakeJQuery = { ajax: function (options) { return options } }
forget(require('jquery'), fakeJQuery)
var module = require('./module.js')

/* Do some testing here */

forget.restore()

Now in your test, you'll use the mocked out version of jquery instead of the real thing.

Author

Thom Blake

License

ISC

1.0.1

9 years ago

1.0.0

9 years ago