Thursday, 11 May 2017

How to use node.js and npm script parameter to run different suites using protractor

I have a package.json with scripts section:

"scripts": {
   "e2e": "npm run protractor",
   "protractor": "protractor protractor.conf.js",
},

Then I have this suites file in protractor.conf.js:

specs: [
  'spec1.js',
  'spec2.js',
  'spec3.js',
  'spec4.js'
],
  suites: {
   "first" : ["spec1.js", "spec2.js"],
   "second": ["spec3.js", "spec4.js"]
}

I want to be able to run a script as:

npm run e2e -- first  // this is supposed to run "protractor --suite=first"
npm run e2e -- second // this is supposed to run "protractor --suite=second"

So my goal is to have one "npm run e2e" command and different suites as a parameter for that script that uses node.js -- parameter. And if I just do the "npm run e2e" the specs from the specs section in protractor.conf.js will be run.



via Jerzy Gruszka

No comments:

Post a Comment