Prevents modules from being loaded when running unit tests.
- Hide multiple modules
- Will fail the same way that
require()
does when a module cannot be found - No dependencies
Install via npm.
npm install require-blocker --save-dev
'use strict';
const requireBlocker = require( 'require-blocker' );
requireBlocker.block( 'http', 'https' );
// require( 'http' ); will fail
// require( 'https' ); will fail
requireBlocker.reset();
// require( 'http' ); will load
// require( 'https' ); will load
We'd love to get feedback on how to make this tool better. Feel free to contact us at [email protected]