requireincontext

0.0.2 • Public • Published

RequireInContext

Allows you to do a require() with a custom context.

Useful for emulating a browser environment in Node:

var requireInContext = require('requireincontext');
var myclient = requireInContext('./myclient.js', {
  window: {},
  io: require('socket.io')
});

Or for specifying mock objects for running tests:

var requireInContext = require('requireincontext');
var mycode = requireInContext('./mycode.js', {
  mydependency: require('./dependency_mock.js')
});

Readme

Keywords

none

Package Sidebar

Install

npm i requireincontext

Weekly Downloads

2

Version

0.0.2

License

none

Last publish

Collaborators

  • mixu