Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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')
});

Keywords

none

install

npm i requireincontext

Downloadsweekly downloads

12

version

0.0.2

license

none

repository

githubgithub

last publish

collaborators

  • avatar