Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

26 lines (16 sloc) 0.573 kB

RequireInContext

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

Installing:

npm install requireincontext

Using:

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')
});
Jump to Line
Something went wrong with that request. Please try again.