【发布时间】:2023-03-20 12:11:01
【问题描述】:
我正在使用 CasperJS 运行自动化前端测试,但在我的测试中使用其他 npm 模块时遇到了问题。我知道patchRequire 但是我相信它只能在测试环境之外调用,因为测试运行程序补丁自动需要。我确实包括了它,但结果是一样的。它说它找不到模块。我已经确认下划线模块安装在项目根文件夹的node_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: 找不到模块下划线
【问题讨论】:
标签: javascript node.js phantomjs casperjs