Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nhz-io/mini-mock

Patch require to return mocks
https://github.com/nhz-io/mini-mock

Last synced: 4 days ago
JSON representation

Patch require to return mocks

Awesome Lists containing this project

README

        

@nhz.io/mini-mock



NPM Version


Bithound Status


License


Downloads

Patch `require()` to return mocks

## Install
```
npm i -D @nhz.io/mini-mock
```

## Usage
```javascript
// will-get-mock.js
const someModule = require('some-module')
...
```

```javascript
// will-get-real.js
const someModule = require('some-module')
...
```

```javascript
// test.js
require('@nhz.io/mini-mock')

module.mock('some-module', 'Mocked value')
require('./will-get-mock.js')

module.unmock('some-module')
require('./will-get-real.js')
...
```

## License

### [MIT](LICENSE)