A test runner agnostic stubbing library for Node.JS, supporting dependency injection and auto stubbing.
A stubbing library with a focus on having:
- A simple API.
- Dependency injection and auto stubbing.
- A decoupled relationship with test runners.
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
var db = mimusrequire'./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.
Set an internal variable.
mimussetrequired_module 'internal_var_name' 'value'
Create a (Sinon.JS) stub.
var stub = mimusstubstubreturns
Create a (Sinon.JS) spy.
var spy = mimusspy
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.
Current issue tracker is on github.
Please read any docs available before opening an issue.
git clone email@example.com:brentlintner/mimus.git cd mimus npm install
npm run test npm run test-cov
npm run lint npm run lint-cov
npm run dev &
The top level API's main goal is to be a one method level interface with the object
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.