clear-require
Clear a module from the require
cache
Useful for testing purposes when you need to freshly require
a module.
Install
$ npm install --save clear-require
Usage
let i = 0;
module.exports = () => ++i;
const clearRequire = require('clear-require');
require('./foo')();
require('./foo')();
clearRequire('./foo');
require('./foo')();
API
clearRequire(moduleId)
moduleId
Type: string
What you would use with require()
.
clearRequire.all()
Clear all modules from the require
cache.
clearRequire.match(regex)
Clear all matching modules from the require
cache.
regex
Type: RegExp
Regex to match against the module ID's.
Related
License
MIT © Sindre Sorhus