4
我使用CasperJS
來運行自動化前端測試,但遇到了在我的測試中使用其他npm模塊的問題。我知道patchRequire
但是我相信只有在測試環境之外才會自動調用測試運行器補丁。我確實包括了它,但結果是一樣的。它說它找不到該模塊。我已經確認下劃線模塊安裝在node_modules
項目的根文件夾中。不能要求帶CasperJS的下劃線
代碼
'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: Can't find module underscore