UNPKG

335 BJavaScriptView Raw
1const sinon = require('sinon')
2
3const clearModuleCache = module => delete require.cache[require.resolve(module)]
4
5const stubModule = async (module, returnVal) => {
6 clearModuleCache(module)
7 require.cache[require.resolve(module)] = {
8 exports: sinon.stub().returns(returnVal),
9 }
10}
11
12module.exports = {
13 clearModuleCache,
14 stubModule
15}
\No newline at end of file