npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mimus

v0.2.8

Published

A test runner agnostic stubbing library for Node.JS, supporting dependency injection and auto stubbing.

Downloads

171

Readme

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!

Installation

npm install mimus

Usage

  var mimus = require('mimus')

mimus.require

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.

mimus.get

Get an internal variable.

Uses rewire.__get__.

  mimus.get(required_module, 'internal_var_name')

mimus.set

Set an internal variable.

Uses rewire.__set__.

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

mimus.stub

Create a (Sinon.JS) stub.

  var stub = mimus.stub()
  stub.returns...

mimus.spy

Create a (Sinon.JS) spy.

  var spy = mimus.spy()

mimus.reset

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

  mimus.reset()

mimus.restore

Calls restore on every (Sinon.JS) stub.

  mimus.restore()

Examples

See the system tests.

Contributing

Current list of contributors.

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

Code Of Conduct

See bantik's contributor covenant!

Issues

Current issue tracker is on github.

Please read any docs available before opening an issue.

Hacking

git clone [email protected]:brentlintner/mimus.git
cd mimus
npm install

Testing

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.

Versioning

This project ascribes to semantic versioning.

Kudos!

  • 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.