I use CasperJSto run automated tests with an interface, but I am having problems using other npm modules in my tests. I know patchRequire, but I believe that this should only be called outside the test environment, since patches for the test runner are automatically required. I turned it on, but the results were the same. It says that he cannot find the module. I confirmed that the underscore is installed in node_modulesthe root folder of the projects.
code
'use strict'
_ = require 'underscore'
testConfig =
testPageUrl: ''
testSearchTerm: 'the'
config = _.extend testConfig, require 'common/config'
Javascript Code
'use strict';
_ = require('underscore');
testConfig = {
testPageUrl: '',
testSearchTerm: 'the'
};
config = _.extend(testConfig, require('common/config'));
Mistake
CasperError: cannot find module underscore
Kylee source
share