How to specify port and host for ng e2e using configuration

How do you set the port and host for the command ng e2eusing the configuration file?

I know that the following statement can be used on the command line

ng e2e --port <port number> --host <host>

This works well, but it would be more convenient to set the port and address in the configuration file. I looked inside .angular-cli.jsonand found that there is a file with a name protractor.config.js, I could not figure out which settings to use in this file, there is a parameter there baseUrl, but changing this does not make a difference with the port used by the command ng e2e. It seems to be using a random port.

Besides baseUrl, I also tried to install portand seleniumPort, but they have no meaning.

After entering the command ng e2e, the following output will appear in the console

** NG Live Development Server is running on http://localhost:49155 **

As protractor.config.jsI have baseUrlset as http://localhost:50000. I watched the tests run, and I see that the browser uses an address http://localhost:49155that is not the desired address.

ng --version returns followin

@ angular / cli: 1.0.0
node: 7.7.1
os: win32 x64
@ angular / general: 4.0.3
@ angular / compiler: 4.0.3
@ angular / core: 4.0.3
@ angular / forms: 4.0.3
@ angular / http: 4.0.3
@ angular / platform browser: 4.0.3
@ angular / platform-browser-dynamic: 4.0.3
@ angular / router: 4.0.3
@ angular / cli: 1.0.0
@ angular / compiler-cli : 4.0.3

+6
2

, dev-, ng e2e

, , NPM script: https://docs.npmjs.com/misc/scripts

  • "e2e":"ng e2e --port <port number> --host <host>" package.json scripts
  • script, npm run e2e, script e2e package.json, ng e2e --port <port number> --host <host>

, .

+7

baseUrl - protractor.config.js, onPrepare config.js

{
    onPrepare() {
        browser.baseUrl = 'http://localhost:4200/';
    },
}

Angular 1.x, Angular 2/4

+2

Source: https://habr.com/ru/post/1016710/


All Articles