I use Angular environment variables to configure API endpoints:
.\src\environments:
environment.ts
environment.test.ts
environment.prod.ts
The environtment files contain settings like the following which are different for local dev and CI servers:
export const environment = {
...
apiUrl: "https://api.sample.com"
};
That works fine when I need to build or start the application. I can simply specify the environment parameter:
ng serve --environment=test
... but it appeared that it's impossible to set a specific environment when running e2e Protractor tests. The following command simply ignores the environment (which seems to be expected according to this comment). The default environment is always used:
ng e2e --environment=test // same as `ng e2e`
Are there any other ways to run the tests using a specific environment?
config
file undere2e
folder, which accepts thebaseUrl
as params. I am passing this param if i need test in production env else local env will considered. But need to run the test via global protractor and not through ng e2e. Again not good solution, To me its work around. – Sameer K