A test runner agnostic stubbing library for Node.JS, supporting dependency injection and auto stubbing.
Last updated 2 years ago by brentlintner .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mimus 
SYNC missed versions from official npm registry.

mimus Circle CI score-badge coverage-badge dependency-badge NPM version

A stubbing library with a focus on having:

  • A simple API.
  • Dependency injection and auto stubbing.
  • A decoupled relationship with test runners.

Note: Currently this project is using Sinon and Rewire. Check them out!


npm install mimus


  var mimus = require('mimus')


This is the main method that you will use. It will require only the module you want to test against, while stubbing any specified internal modules, that can be retrieved with other methods.

Require a stubbed db module and also stub the mongodb and zlib module.

  var db = mimus.require('./lib/db', __dirname, ['mongodb', 'zlib'])

Why the whitelist approach?

This way, unexpected clashes with mocking low level modules can be controlled by the user.


Get an internal variable.

Uses rewire.__get__.

  mimus.get(required_module, 'internal_var_name')


Set an internal variable.

Uses rewire.__set__.

  mimus.set(required_module, 'internal_var_name', 'value')


Create a (Sinon.JS) stub.

  var stub = mimus.stub()


Create a (Sinon.JS) spy.

  var spy = mimus.spy()


Calls reset on every (Sinon.JS) stub/spy.



Calls restore on every (Sinon.JS) stub.



See the system tests.


Current list of contributors.

Any contributions are welcome. Please consider tests and code quality before submitting.

Code Of Conduct

See bantik's contributor covenant!


Current issue tracker is on github.

Please read any docs available before opening an issue.


git clone git@github.com:brentlintner/mimus.git
cd mimus
npm install


npm run test
npm run test-cov

Code Quality

npm run lint
npm run lint-cov

Auto Compiling CoffeeScript

npm run dev &

Architectural Notes

The top level API's main goal is to be a one method level interface with the object returned via mimus.require being passed around by reference. This keeps api methods off of the main object, and also provides a more functional way to interact with mimus.


This project ascribes to semantic versioning.


  • Sinon is currently used underneath.
  • For dependency injection, Rewire is used.
  • Inspiration could not have happened with seeing Jest in action.

Also, see all other deps.

Current Tags

  • 0.2.8                                ...           latest (2 years ago)

15 Versions

  • 0.2.8                                ...           2 years ago
  • 0.2.7                                ...           3 years ago
  • 0.2.6                                ...           3 years ago
  • 0.2.5                                ...           3 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 5
Dependencies (6)
Dev Dependencies (15)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |