I\'m using CasperJS to run automated frontend tests but have run in to an issue with using other npm modules in my tests. I\'m aware of patchRequire
CasperJS
patchRequire
So solution I eventually found was to create proxy modules that import the npm module and export it out to the casper script.
./proxies/underscore.js:
module.exports = require('underscore');
./tests/test.js
var _ = require('../proxies/underscore');