asl
asl

Reputation: 87

use baseUrl from CLI instead of protractor config

I am using angular CLI 7 and protractor 5.4.2. I want my protractor tests to use the baseUrl from CLI instead of protractor config. I have tried the below.

ng e2e --base-url="https://google.com"

Only to see :

Option "baseUrl" is deprecated: Use "baseUrl" in the Protractor config file instead.
The 'baseUrl' option cannot be used with 'devServerTarget'.
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
Error: The 'baseUrl' option cannot be used with 'devServerTarget'.
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
    at ProtractorBuilder.run 

Any body who experienced this before ? How can I use the baseUrl otherwise.

Thanks

Upvotes: 0

Views: 1530

Answers (2)

Ninja
Ninja

Reputation: 130

I did the following trick and it worked for me :

I updated my angular.json file and added a new parameter configurations

"e2e": {
      "root": "e2e/",
      "projectType": "application",
      "prefix": "",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/local.js",
            "devServerTarget": "ng:serve"
          },
          "configurations": {
            "env": {
              "protractorConfig": "e2e/protractorconf.js",
              "devServerTarget": ""
            }
          }
        },

It works when I run

ng e2e -c env --baseUrl="https://google.com"

-c is the configurations specified in angular.json.

Refer to https://angular.io/cli/e2e for more options

Upvotes: 2

Kuba Lubas
Kuba Lubas

Reputation: 91

Try this, for me, it works.

protractor protractor.conf.js --params.baseUrl 'https://google.com'

Upvotes: 2

Related Questions