我在Jenkins中使用浏览器堆栈插件,使用量角器进行e2e测试。 E2e在本地工作正常,但是当部署在Jenkins运行e2e测试时会出现以下错误。
Connecting local error { LocalError: Could not connect to Files!
at C:\Program Files (x86)\Jenkins\workspace\Angular UI Toolkit\node_modules \browserstack-local\lib\Local.js:57:20
at ChildProcess.exithandler (child_process.js:197:7)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
name: 'LocalError',
message: 'Could not connect to Files!',
extra: undefined }
这是我的浏览器stack.config文件。
var browserstack = require('browserstack-local');
exports.config = {
'seleniumAddress': 'http://hub-cloud.browserstack.com/wd/hub',
baseUrl: 'http://localhost:3000/',
ignoreSynchronization: false,
framework: 'jasmine',
allScriptsTimeout: 110000,
getPageTimeout: 50000,
jasmineNodeOpts: {
// showTiming: true,
showColors: true,
isVerbose: false,
includeStackTrace: false,
defaultTimeoutInterval: 5000000
},
specs: [
'./dist/demo-app/**/*.e2e-spec.js'
],
exclude: [],
'capabilities': {
'browserstack.user': 'username',
'browserstack.key': 'key',
'browserstack.local': true,
'browserstack.localIdentifier':'test123',
'os': 'Windows',
'os_version': '8.1',
'browserName': 'IE',
'browser_version': '11.0'
},
// Code to start browserstack local before start of test
beforeLaunch: function(){
console.log("Connecting local");
return new Promise(function(resolve, reject){
exports.bs_local_args = {
key: exports.config.capabilities['browserstack.key'],
localIdentifier:exports.config.capabilities['browserstack.localIdentifier'],
force: true
};
exports.bs_local = new browserstack.Local();
console.log('exports.bs_local BROWSERSTACK_USERNAME...',process.env.BROWSERSTACK_USERNAME);
console.log('exports.bs_local...',exports.bs_local);
exports.bs_local.start(exports.bs_local_args, function(error) {
if (error){
console.log("Connecting local error",error);
return reject(error);
}
console.log('Connected. Now testing...');
resolve();
});
});
},
// Code to stop browserstack local after end of test
afterLaunch: function(){
return new Promise(function(resolve, reject){
exports.bs_local.stop(resolve);
});
},
useAllAngular2AppRoots: true
};
答案 0 :(得分:0)
我有同样的问题,并通过在我的配置中添加'logFile'来解决它
exports.bs_local_args = {
key: exports.config.capabilities['browserstack.key'],
localIdentifier:exports.config.capabilities['browserstack.localIdentifier'],
force: true
logFile: '<path-to-log>'
};