Skip to content
Simple module dependency mocking
Find file
Latest commit 6c5a1cf @mlmorg Bump version
Failed to load latest commit information.
lib Lint files
test Lint files
.gitignore Add tests
LICENSE Initial commit
Makefile Lint files Update readme.
package.json Bump version


Mockit is a simple library for mocking module dependencies during testing. Other dependency injection libraries create a sandbox around the tested module forcing the user to deal with an entirely new module context. Mockit simply overwrites the mocked dependencies and includes the module in its original scope.


$ npm install mockit


To mock the http module in a required file:

var mockit = require('mockit');

var mockHttp = {
  // Mocked methods here...

var Downloader = mockit('../lib/downloader', {
  http: mockHttp
Something went wrong with that request. Please try again.