1

I'm trying to run my test-build on TeamCity using just grunt command, but it throw me error. The odd thing is - when I write grunt command in my terminal locally (not on Teamcity agent) all works fine. I've got input like 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.

But when I try to perform it via TeamCity... I've got this:

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

Versions of Node.js, npm and Protractor on my computer and on the TeamCity agent are the same.

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'
       }));
   }
};

Spend all day googling and searching but still dunno why locally all works and on TC not. Maybe it's because I'm using Grunt and TeamCity just week? : ) I dunno. Any help will be GREATLY appreciated.
EDIT
forgot to tell TC version - TeamCity Professional 9.1.7
still dunno how to figure out this problem, already in despair :) trying to rewrite stuff from Protractor to Karma, but as I understand it's using only to unit tests, while I need E2E (imitate user clicking, filling forms etc)...

impregnable fiend
  • 289
  • 1
  • 5
  • 16
  • Very much similar symptoms: http://stackoverflow.com/questions/36789889/syntaxerror-use-of-const-in-strict-mode. – alecxe Jul 27 '16 at 17:07
  • @alecxe yeah, but his solution didn't work for me. – impregnable fiend Jul 27 '16 at 18:49
  • Looking for possibilities...Is it possible that you followed the directions from the other post but as yourself and not the user running TeamCity (so maybe cleared a different cache location)? – dcbyers Jul 28 '16 at 15:26
  • @dcbyers solution in that post is to update nodejs. Like I mentioned in my post on my computer and on TC node is up to date – impregnable fiend Jul 28 '16 at 15:52

0 Answers0