You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
* This function is needed to determine the calling parent module.
7
5
* Thus rewire acts exactly the same like require() in the test module.
8
6
*
9
7
*@param {!String} request Path to the module that shall be rewired. Use it exactly like require().
10
-
*@param {Object} mocks An object with mocks. Keys should be the exactly same like they're required in the target module. So if you write require("../../myModules/myModuleA.js") you need to pass {"../../myModules/myModuleA.js": myModuleAMock}.
11
-
*@param {Object} injections If you pass an object, all keys of the object will be vars within the module. You can also eval a string. Please note: All scripts are injected at the end of the module. So if there is any code in your module that is executed during require(), your injected variables will be undefined at this point. For example: passing {console: {...}} will cause all calls of console.log() to throw an exception if they're executed during require().
12
-
*@param {Array} leaks An array with variable names that should be exported. These variables are accessible via myModule.__
13
8
*@param {Boolean} cache Indicates whether the rewired module should be cached by node so subsequent calls of require() will return the rewired module. Subsequent calls of rewire() will always overwrite the cache.
14
9
*@return {*} the rewired module
15
10
*/
@@ -23,6 +18,16 @@ function rewire(request, cache) {