I've been currently migrating my app from 4 to 6 and I can not executing my proxy script for my e2e tests.
The script listing looks as follows:
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:tst1": "ng serve --proxy-config config/proxy/proxy.tst1.json",
"start:tst5": "ng serve --proxy-config config/proxy/proxy.tst5.json",
...
"test:watch": "ng test",
"lint": "ng lint --type-check true",
"e2e": "ng e2e",
"e2e:tst1": "ng e2e --proxy-config config/proxy/proxy.tst1.json",
"e2e:tst5": "ng e2e --proxy-config config/proxy/proxy.tst5.json",
},
What I don't understand is, that the start commands (ng serve) work perfectly fine for instancenpm run start:tst5
. But when I try to execute the e2e tests like npm run e2e:tst5
it throws me the error: Unknown option: '--proxyConfig'
.
The config in my angular.json looks as follows:
angular.json
...
"lmsbo-bo-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "lmsbo-bo:serve"
},
"configurations": {
"production": {
"devServerTarget": "lmsbo-bo:serve:production"
}
}
},
...
Edit
I got the e2e test working with following addition in the angular.cli
:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "lmsbo-bo:build",
"proxyConfig": "config/proxy/proxy.tst5.json" <== **added this** line
},
"configurations": {
"production": {
"browserTarget": "lmsbo-bo:build:production"
}
}
},
But this solution approach is not satisfying by any means. I got to change this line of code every time I want to execute against another environment. I would rather want to manage this via command line by writing something like: ng serve --proxy-config config/proxy/proxy.tst5.json
.
ng serve --proxy-config config/proxy/proxy.tst1.json
it works all fine. But when i replaceserve
withe2e
the error appears. Im kind of frustrated.... – SuperabundantproxyConfig: ....
and then execute different paths via ng serve---proxyOptions=...
? – Superabundantconfig/proxy/proxy.tst5.json
? – Irtysh