Javascript Can';不需要带下划线的CasperJS
我正在使用Javascript Can';不需要带下划线的CasperJS,javascript,node.js,phantomjs,casperjs,Javascript,Node.js,Phantomjs,Casperjs,我正在使用CasperJS运行自动化前端测试,但在测试中遇到了使用其他npm模块的问题。我知道patchRequire,但是我认为这只能在测试环境之外调用,因为测试运行程序补丁需要自动调用。我确实包括了它,但结果是一样的。它说找不到模块。我已确认下划线模块已安装在项目根文件夹的node\u modules中 代码 'use strict' _ = require 'underscore' testConfig = testPageUrl: '' testSearchTerm:
CasperJS
运行自动化前端测试,但在测试中遇到了使用其他npm模块的问题。我知道patchRequire
,但是我认为这只能在测试环境之外调用,因为测试运行程序补丁需要自动调用。我确实包括了它,但结果是一样的。它说找不到模块。我已确认下划线模块已安装在项目根文件夹的node\u modules
中
代码
'use strict'
_ = require 'underscore'
testConfig =
testPageUrl: ''
testSearchTerm: 'the'
config = _.extend testConfig, require 'common/config'
Javascript代码
'use strict';
_ = require('underscore');
testConfig = {
testPageUrl: '',
testSearchTerm: 'the'
};
config = _.extend(testConfig, require('common/config'));
错误
CasperError:找不到模块下划线
所以我最终找到的解决方案是创建代理模块,导入npm模块并将其导出到casper脚本
/proxies/underline.js:
module.exports = require('underscore');
/tests/test.js
var _ = require('../proxies/underscore');