# mock

> Load a module with it's require's mocked out

Latest version **0.1.1** (published 2013-01-29) · 0 weekly downloads

## Install

```sh
npm install mock
pnpm add mock
yarn add mock
bun add mock
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2013-01-29 |
| First published | 2013-01-23 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Raynos |
| Maintainers | raynos |

## Links

- npm: https://www.npmjs.com/package/mock
- Repository: https://github.com/Colingo/mock
- Issues: https://github.com/Colingo/mock/issues
- npm.io page: https://npm.io/package/mock

## Recent versions

- 0.1.1 (latest) — 2013-01-29
- 0.1.0 — 2013-01-23

## README

# mock

[![build status][1]][2]

[![browser support][3]][4]

Load a module with it's require's mocked out

Works in both node and browserify

## Example

```js
var realB = require("./fixtures/b")

var b = mock("./fixtures/b", {
    fs: {
        readFileSync: function (uri) {
            if (uri === "clowns.txt") {
                return "some clowns"
            }
        }
    }
    , "./fixtures/c": null
    , "./fixtures/a": function () {
        return 42
    }
}, require)

// use b. It's reference to fs and fixtures/a have been replaced with
// your passed objects
```

Limitations:

 - You have to require the thing your mocking out or browserify
    won't load it and all it's dependencies into the bundle.
 - When you set a dependency to null your saying don't overload
    that dependency with this value, but do nuke it from the cache.
    This is useful when you want to mock out something ./fixtures/c
    depends on but not touch the implementation of ./fixtures/c

## Installation

`npm install mock`

## Contributors

 - Raynos

## MIT Licenced

  [1]: https://secure.travis-ci.org/Colingo/mock.png
  [2]: http://travis-ci.org/Colingo/mock
  [3]: http://ci.testling.com/Colingo/mock.png
  [4]: http://ci.testling.com/Colingo/mock

---
_Source: https://npm.io/package/mock · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
