我正在尝试使用test-build
命令在TeamCity上运行我的grunt
,但它让我犯了错误。奇怪的是 - 当我在本地终端(而不是Teamcity代理)上编写grunt
命令时,一切正常。我有输入 this :
impregnable@linux-dev-ort:~/dev/captcha-dev$ grunt
Running "jshint:files" (jshint) task
>> 3 files lint free.
Running "protractor:singlerun" (protractor) task
[19:08:51] I/local - Starting selenium standalone server...
[19:08:51] I/launcher - Running 1 instances of WebDriver
[19:08:52] I/local - Selenium standalone server started at http://192.168.1.117:55627/wd/hub
Started
........
8 specs, 0 failures
Finished in 19.148 seconds
[19:09:12] I/local - Shutting down selenium standalone server.
[19:09:12] I/launcher - 0 instance(s) of WebDriver still running
[19:09:12] I/launcher - chrome #01 passed
Done.
但是当我尝试通过TeamCity执行它时... 我有这个:
Step 1/1: Run captcha tests via Protractor (Command Line)
[18:25:21][Step 1/1] Starting: /var/buildAgent/temp/agentTmp/custom_script2979762391918001494
[18:25:21][Step 1/1] in directory: /var/buildAgent/work/bc9e47ac95c1cdb2
[18:25:22][Step 1/1] Running "jshint:files" (jshint) task
[18:25:22][Step 1/1] >> 3 files lint free.
[18:25:22][Step 1/1]
[18:25:22][Step 1/1] Running "protractor:singlerun" (protractor) task
[18:25:22][Step 1/1]
[18:25:22][Step 1/1] /var/buildAgent/work/bc9e47ac95c1cdb2/captcha-dev/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/index.js:25
[18:25:22][Step 1/1] const builder = require('./builder');
[18:25:22][Step 1/1] ^^^^^
[18:25:22][Step 1/1] SyntaxError: Use of const in strict mode.
[18:25:22][Step 1/1] at Module._compile (module.js:439:25)
[18:25:22][Step 1/1] at Object.Module._extensions..js (module.js:474:10)
[18:25:22][Step 1/1] at Module.load (module.js:356:32)
[18:25:22][Step 1/1] at Function.Module._load (module.js:312:12)
[18:25:22][Step 1/1] at Module.require (module.js:364:17)
[18:25:22][Step 1/1] at require (module.js:380:17)
[18:25:22][Step 1/1] at Object.<anonymous> (/var/buildAgent/work/bc9e47ac95c1cdb2/captcha-dev/node_modules/grunt-protractor-runner/node_modules/protractor/built/driverProviders/driverProvider.js:8:17)
[18:25:22][Step 1/1] at Module._compile (module.js:456:26)
[18:25:22][Step 1/1] at Object.Module._extensions..js (module.js:474:10)
[18:25:22][Step 1/1] at Module.load (module.js:356:32)
[18:25:22][Step 1/1] >> /var/buildAgent/work/bc9e47ac95c1cdb2/captcha-dev/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/index.js:25
[18:25:22][Step 1/1] >> const builder = require('./builder');
[18:25:22][Step 1/1] >> ^^^^^
[18:25:22][Step 1/1] >> SyntaxError: Use of const in strict mode.
[18:25:22][Step 1/1] >> at Module._compile (module.js:439:25)
[18:25:22][Step 1/1] >> at Object.Module._extensions..js (module.js:474:10)
[18:25:22][Step 1/1] >> at Module.load (module.js:356:32)
[18:25:22][Step 1/1] >> at Function.Module._load (module.js:312:12)
[18:25:22][Step 1/1] >> at Module.require (module.js:364:17)
[18:25:22][Step 1/1] >> at require (module.js:380:17)
[18:25:22][Step 1/1] >> at Object.<anonymous> (/var/buildAgent/work/bc9e47ac95c1cdb2/captcha-dev/node_modules/grunt-protractor-runner/node_modules/protractor/built/driverProviders/driverProvider.js:8:17)
[18:25:22][Step 1/1] >> at Module._compile (module.js:456:26)
[18:25:22][Step 1/1] >> at Object.Module._extensions..js (module.js:474:10)
[18:25:22][Step 1/1] >> at Module.load (module.js:356:32)
[18:25:22][Step 1/1] Warning: Tests failed, protractor exited with code: 8 Use --force to continue.
[18:25:22][Step 1/1]
[18:25:22][Step 1/1] Aborted due to warnings.
[18:25:22][Step 1/1] Process exited with code 8
[18:25:22][Step 1/1] Step Run captcha tests via Protractor (Command Line) failed
我的计算机和TeamCity代理上的Node.js,npm和Protractor的版本是相同的。
node v6.2.2
npm v3.9.5
protractor 4.0.0
Gruntfile.js :
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['Gruntfile.js', 'Client/Test_E2E/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
},
loopfunc:true
}
},
protractor: {
options: {
keepAlive: true,
configFile: "Client/Test_E2E/conf.js"
},
singlerun: {},
auto: {
keepAlive: true,
options: {
args: {
directConnect: true
// seleniumServerJar: 'node_modules/grunt-protractor-runner/node_modules/protractor/selenium/selenium-server-standalone-2.52.0.jar'
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.registerTask('default', ['jshint', 'protractor:singlerun']);
};
conf.js :
exports.config = {
allScriptsTimeout: 11000,
specs: [
'test.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:55555/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'testresults',
filePrefix: 'xmloutput'
}));
}
};
花一整天的谷歌搜索和搜索,但仍然不知道为什么本地所有工作和TC不。也许是因为我一周都在使用Grunt和TeamCity? : ) 我不知道。任何帮助都将非常感激。
的修改
忘了告诉TC版 - TeamCity Professional 9.1.7
仍然不知道如何弄清楚这个问题,已经在绝望:)尝试重写从量角器到Karma的东西,但据我所知,它只用于单元测试,而我需要E2E(模仿用户点击,填写表格等)...