“ng e2e” is failling probably in reason of proxy but “ng serve” and “ng test” are working

£可爱£侵袭症+ 提交于 2019-12-04 17:07:57

1) when you run ng e2e, it report error: Error: connect ETIMEDOUT x.x.x.x:443

because the default value of option --webdriver-update of ng e2e is true, and your network behind proxy, so without telling your network proxy to webdriver-manager, webdriver-manger update will fail to connect network, this's why you see the error.

I looked into the source code of ng e2e at https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/tasks/e2e.ts, and noticed we can't pass the proxy by following behind npm run e2e, but we can set proxy in Enviroment Variable which webdriver-manager will read before running, you can follow below post to set proxy in Environment Varable: how to check what is causing webdriver-manager to fail

2) when you run ng e2e --no-webdriver-update to skip webdriver update, it report error: Error message: Could not find update-config.json

It means the update-config.json not exist in project_folder\node_modules\protractor\node_modules\webdriver-manager\selenium

Because you used the global webdriver-manger to execute webdriver update, rather than the project local webdriver-manager (at project_folder\.bin\webdriver-manager).

The correct way is switch to your_project folder in cmd window firstly, then execute node_modules\.bin\webdriver-manager update --proxy http://myproxy.vm.mycompany.net:3128 Then the update-config.json will be there and ng e2e --no-webdriver-manager should work now.

ng e2e can't use global webdriver-manager, but only project local node_modules\.bin\webdriver-manger

npm proxy VS environment variable proxy

1) npm proxy

npm proxy only work for the command: npm and this command implement won't read proxy from evniroment variable, thus you have to set proxy for npm by command npm config set or directly modify .npmrc file under user home or project folder.

2) environment variable proxy

Only tool/soft/program/command which implement will read proxy setting from environment variable, then the environment variable proxy can effect on them.

It's not easy for user to know environment variable proxy will effect on a tool/soft/program/command, especially it's a new thing we touch for first time.

But in generally, we can think everything executed from command window will read proxy setting from environment variable, but it's not always this, Like npm, it only read proxy from itself proxy setting.

Now back to the webdriver-manager, first it executed from command window in most case, actually the final determiner to decide environment variable proxy will effect on it or not is the implement itself.

In webdriver-manager implement, firstly, it will read proxy passed as options in command line as following: webdriver-manager update --proxy http://proxy.company.com:1234

If you not pass proxy in command line, then it will read proxy from environment variable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!