How to pass parameters from npm command to protractor config file
I have protractor config file:
exports.config = {
allScriptsTimeout : 30000,
suites : {
login2 : 'e2e/TestSuites/Full/LoginTestSuite/ValidInvalidLogins.js',
},
// configure multiple browsers to run tests
multiCapabilities : [
{
'browserName' : 'chrome'
//'browserName': 'firefox'
} ],
baseUrl :'http://localhost:8080',
framework : 'jasmine2',
jasmineNodeOpts : {
defaultTimeoutInterval : 30000
},
};
and npm package.json file :
"scripts": {
"e2e-bvt": "protractor tests/protractor-conf-BVT.js --baseUrl $baseUrl",
},
I want to pass --baseUrl = http://testurl:8080 to npm command so that protractor config file can take this parameter to run test against different baseUrl.
how can I achieve something like:
npm run e2e-bvt --$baseUrl=http://testurl:8080
You need to add "--" next to your npm run command and then pass all required parameters.
"scripts": {
"e2e-bvt": "protractor tests/protractor-conf-BVT.js",
}
npm run e2e-bvt -- --baseUrl=http://testurl:8080
the above command will take all the argumnets (--baseUrl=http://testurl:8080) and pass this argument to the script e2e-bvt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With