Angular migration (from 4 to 6) e2e --proxy-config not working
You can accomplish this by updating your angular.json as follows (substitute your project name for my-project):
1) In projects -> my-project-e2e, update devServerTarget from
"my-project:serve"
to
"my-project:serve:e2e"
2) In projects -> my-project -> architect -> configurations, add
"e2e": {
"browserTarget": "cli-advisor-portal:build:e2e",
"proxyConfig": "proxy.local.config.json"
}
Even though this feature is not supported anymore and there is already an open issue on github, Ive found out a pretty convinient way to execute the proxy config via script
:
add in your package.json following lines (example):
"e2e:local": "ng config projects.**yourAppName**.architect.serve.options.proxyConfig **yourProxyFile1** && ng e2e && ng config projects.**yourAppName**.architect.serve.options.proxyConfig ''",
"e2e:tst1": "ng config config projects.**yourAppName**.architect.serve.options.proxyConfig **yourProxyFile2** && ng e2e && ng config projects.**yourAppName**.architect.serve.options.proxyConfig ''"
All you do is to set the proxyConfig
value in your angular.json
via ng
command and reset it after the e2e tests are finished. Make sure the ng
command is working (if not add your angular/cli
path into your environment properties of your operating System and restart your computer).