“Globals”在量角器4.0.0中没有按预期工作?

时间:2016-07-20 17:41:54

标签: protractor

我们在onPrepare文件的config函数中有以下设置 -

exports.config = {

directConnect: true,
baseUrl: env.baseUrl,
capabilities: env.capabilities,

onPrepare: function () {
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
global.expect = chai.expect; // by removing this line error is not thrown
browser.manage().window().maximize();
},

setDefaultTimeout : 60 * 1000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [
'../Features/*.feature'
],

cucumberOpts: {
monochrome: true,
strict: true,
plugin: ["pretty"],
require: ['../StepDefinitions/*.js', '../Support/*.js'],
tags:'@AddActiveTip,@AddInActiveTip,~@AddActiveManufacturer,~@AddInActiveManufacturer'
//tags:'@TestSplitText'
}
};

自升级到量角器4.0以来,我收到以下错误,浏览器无限期挂起,无论如何错误无助于调试。

错误:

 > protractor Config/config.js --troubleshoot

 [22:38:12] I/direct - Using FirefoxDriver directly...
 [22:38:12] I/launcher - Running 1 instances of WebDriver
/Users/pasalar/protractor/psms-protractor/node_modules/protractor/built/exitCodes.js:87
            if (e.message.indexOf(errMsg) !== -1) {
                         ^
TypeError: Cannot read property 'indexOf' of undefined
at Function.ErrorHandler.isError (/Users/pasalar/protractor/psms-protractor/node_modules/protractor/built/exitCodes.js:87:30)
at Function.ErrorHandler.parseError (/Users/pasalar/protractor/psms-protractor/node_modules/protractor/built/exitCodes.js:98:26)
at process.<anonymous> (/Users/pasalar/protractor/psms-protractor/node_modules/protractor/built/launcher.js:169:54)
at emitOne (events.js:82:20)
at process.emit (events.js:169:7)
at process.emit (/Users/pasalar/protractor/psms-protractor/node_modules/protractor/node_modules/source-map-support/source-map-support.js:419:21)
at process._fatalException (node.js:224:26)
npm ERR! Test failed.  See above for more details.

是否还有其他人遇到此问题?我有什么重大改变吗?

1 个答案:

答案 0 :(得分:1)

显示的错误消息与“globals”无关,它按预期工作!由于网络延迟问题,我的脚本随机失败。但是由于用户不知道导致错误的原因,错误消息需要改进!

将其标记为已关闭,因为我可以调试此问题!