I am new to Protractor
. I have developed few tests cases to accomplish the end to end testing. These test cases works fine in all 3 different environments that we have : dev
, testing
and production
.
But I need to change Angular application URL in test cases with respect the environment in which testing needs to be done (as the URL differs from environment to environment).
I am using Angular CLI command ng e2e
to run the test. Now my questions are
1) Is it possible to pass params ng e2e
, so that based on params, URL can be set dynamically inside test cases ?
2) Is it necessary to install protractor
globally, Since Angular CLI creates the angular application with protractor
under node_modules
?
In my project set up, Protractor
version is 5.1.2 and Angular CLI
version is 1.2.0.
Below is Protract
configuration
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
}
};
I tried couple of things like adding params:[env:dev]
and passed the parameter in command line as ng e2e params.env=test
, But I always get the default values and not the values passed from command line.
I also tried @cnishina answer, but console.log of process.env
does not have needed details.
export TEST_ENV=dev
. Which file will have this export statement?? – Summersummerhouse