0.0.4 • Published 9 years ago
require-me v0.0.4
require-me
Require uncached module with mocks
Note: This module works in browsers and Node.js >= 4.0
Installation
npm install require-meUsage
const requireMe = require('require-me');
const otherDep1Mock = require('./mocks/other-module-dep1.mock');
const otherModule = requireMe('other-module', {
mocks: {
'../lib/other-module-dep1': otherDep1Mock,
'./../lib/other-dep2': './mocks/other-dep2.mock',
},
pristine: true
})API
modulePath (String) - Module name or path
options (Object)
mocks(Object) - Map of mocks of module dependencies as{'module_dependency_path': 'mock_path'}.module_dependency_pathandmock_pathresolves relatively current file. You can use object or function instead ofmock_path. It use mock-require for mockingpristine(Boolean) - Clean npm cache before loadingdeep(Boolean) - Clean npm cache for submodules except external and system modules
Return value (Any): Module.exports
Tests
npm install
npm test