Skip to content

ng e2e's serve param does not working #10741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pengx17 opened this issue May 9, 2018 · 7 comments
Closed

ng e2e's serve param does not working #10741

pengx17 opened this issue May 9, 2018 · 7 comments

Comments

@pengx17
Copy link

pengx17 commented May 9, 2018

Versions

Angular CLI: 6.0.0
Node: 8.9.1
OS: darwin x64
Angular: 6.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/flex-layout              6.0.0-beta.15
@angular/material                 6.0.1
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

ng e2e --serve=false

Observed behavior

cli will serve the app on port 4200 as default and ignoring the serve param.

Desired behavior

should not serve the app when serve is false.

Mention any other details that might be useful (optional)

I suspect that the issue is caused by angular.json config after upgrade my app from 5.2 to 6.0. The e2e project section is shown below:

"my-app-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./e2e/protractor.conf.js",
            "devServerTarget": "my-app:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": ["e2e/tsconfig.json"],
            "exclude": ["**/node_modules/**"]
          }
        }
      }
    },

Since the e2e's architect has its option devServerTarget pointing to my-app:serve, it looks like e2e does not pick up the serve param and thus will use devServerTarget regardless.

The workaround I found is to add a new project section copying all content of the e2e project and remove devServerTarget option, then run ng e2e referencing the new project.

@Smileydude
Copy link

A little cleaner of a fix, you can use a browserTarget in your build options of the new project
"e2e-no-serve": { "root": "root", "sourceRoot": "src", "projectType": "application", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "browserTarget": "orginal:build" } }, "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "./protractor.conf.js", } } } },

@rkorrelboom
Copy link

rkorrelboom commented May 23, 2018

The solutions mentioned above seem to work. For the sake of completeness:

Add a new project like this in angular.json:

{
  ...
  "projects": {
    ...,
    "e2e-no-serve": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./e2e/protractor.conf.js"
          }
        }
      }
    }
  }
}

Run with ng e2e --project=e2e-no-serve or npm run e2e -- --project=e2e-no-serve


Or: add a configuration to the existing e2e project like so:

...
    "<my-project>-e2e": {
      ...
      "architect": {
        "e2e": {
          ...
          "configurations": {
            "noserve": {
              "devServerTarget": ""
            }
          }
        },
      ...
      }
    }
...

Run with ng e2e --configuration=noserve or npm run e2e -- --configuration=noserve

@JounQin
Copy link
Contributor

JounQin commented Jun 5, 2018

I have a different issue related:

ng e2e --webdriver-update=false --serve=false
Unknown option: '--serve'

OK, after reading #10699 (comment), it should be

ng e2e --webdriver-update=false --devServerTarget=''

@clydin
Copy link
Member

clydin commented Jun 7, 2018

Closing as resolved based on the answers above.

@clydin clydin closed this as completed Jun 7, 2018
@andradf
Copy link

andradf commented Jun 20, 2018

ng e2e --webdriver-update=false --devServerTarget=''

If running from windows cmd, use --devServerTarget=
That is, without the single quotes. or you can also use double quotes.

@jelling
Copy link

jelling commented Oct 14, 2018

Why not just re-implement the feature? We're hacking around something that should be easy, if not the default.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants