SandyRocks
SandyRocks

Reputation: 297

How to launch protractor instance multiple times from Grunt task

I am trying to launch protractor multiple times from a grunt task like this

grunt.registerTask('makeapps', 'Create Apps', function(count) {

      console.log('value of count is' + count);
      var done=this.async();

      for(var i=1 ;i <= count; i++)
      {

              grunt.initConfig({

              protractor: {
                options: {
                  configFile: "./createAppConf.js", // Default config file which includes protractor tests and other dependencies such as HTML protractor screenshot reporter
                  keepAlive: true, // If false, the grunt process stops when the test fails.
                  noColor: false, // If true, protractor will not use colors in its output.
                  args: {
                    // Arguments passed to the command
                  }

                },
                your_target: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
                  options: {
                    configFile: "createAppConf.js", // // Default config file which includes protractor tests and other dependencies such as HTML protractor screenshot reporter
                    args: {} // Target-specific arguments
                  }
                },
              },
             })

              grunt.loadNpmTasks('grunt-protractor-runner');
       }  

       done();

});

I run the task like this

grunt makeapps:3 protractor

I am able to launch protractor and the test once only. I am not able to launch it multiple times. Can anyone please tell me what I am doing wrong?

Upvotes: 1

Views: 153

Answers (1)

vvondra
vvondra

Reputation: 3162

Your solution would run the function you have and the protractor task defined alongside it. Grunt is more declarative, it first collects task definitions and then you can trigger them.

What about using https://github.com/sindresorhus/grunt-concurrent or https://github.com/iammerrick/grunt-parallel?

Upvotes: 0

Related Questions