Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/nhz-io/mini-mock
- Owner: nhz-io
- License: mit
- Created: 2016-09-11T14:31:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-11T16:23:51.000Z (over 8 years ago)
- Last Synced: 2024-05-02T02:19:29.869Z (8 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@nhz.io/mini-mock
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)