stubrequire
Automatically create stubbed-out versions of node.js modules, ala Jest's autoMock.
Usage:
// BigComplexModule.jsmoduleexports = { return 42; }; // foo.jsmodule { return ;}; // foo-test.jsvar stubRequire = 'BigComplexModule' foo = ; ; // returns undefined, not 42.
stubrequire will mock out both methods and classes, i.e. if a module exports
module.foo
, then new module.foo()
will return an object with the same
methods as the original, but all stubbed out.
Installation
npm install --save-dev stubrequire