Vishwanath Rawat
Vishwanath Rawat

Reputation: 497

Found extra flags error in new version of protractor

I am trying to run a js scripts using protractor, but i am getting following error

C:\Users\Hoodi\AppData\Roaming\npm\node_modules\protractor\built\cli.js:172
        throw new Error('Found extra flags: ' + unknownKeys.join(', '));
        ^

Error: Found extra flags: identityManagement
    at Object.<anonymous> (C:\Users\Hoodi\AppData\Roaming\npm\node_modules\protractor\built\cli.js:172:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Hoodi\AppData\Roaming\npm\node_modules\protractor\bin\protractor:5:1)
    at Module._compile (module.js:570:32)

My config file

// conf.js
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  useAllAngular2AppRoots: true,

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    // Use colors in the command line report.
    showColors: true,

    // Default time to wait in ms before a test fails.
    defaultTimeoutInterval: 60000,
  },

  onPrepare: function() {
      require('../../lib/waitReady.js');
  },

  capabilities :{
      browserName : 'chrome',
  }
}

console.dir("argv: " + process.argv)

switch(process.argv[3]) {
    case '--identityManagement':
        exports.config.specs = ['./identityManagement.js'];
        break;
    default:
        exports.config.specs = ['./identityManagement.js'];
}

I tried executing above script using protractor as well as "npm run" command, but in both cases i am getting same error. command that i used

protractor ./conf.js --identityManagement

and

npm run im

This actually works on my other system. npm and node version of system where this works are

node v7.2.1
npm  v3.10.10

And where is doesnt work

node v7.4.0
npm  v4.0.5

My package.json file looks like this

{
  "name": "intelliflash",
  "author": "Vishwanath Rawat <[email protected]>",
  "description": "IntelliFlash tests",
  "scripts": {
    "im": "protractor ./conf.js --identityManagement"
  }
}

Please help.

Upvotes: 3

Views: 1753

Answers (1)

Ram Pasala
Ram Pasala

Reputation: 5231

It has nothing to do with your npm or node versions, Latest release of Protractor 5.0 has put a check in cli for unidentified flags as you are putting with the help of process.argv.

You can solve this by disabling the flag checks:

 protractor ./conf.js --identityManagement --disableChecks

For more details please refer the Protractor 5.0 changelog

Note: min node version now is v6.9.x which supports this version of protractor

Upvotes: 5

Related Questions