Skip to content
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

ng e2e - Protractor's browser.baseUrl Doesn't Match baseHref Build Option Anymore #15522

Closed
CatGuardian opened this issue Sep 4, 2019 · 1 comment · Fixed by #15530
Closed
Labels
Milestone

Comments

@CatGuardian
Copy link

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [x ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 7.1.3

Description

When running ng e2e before with a baseHref specified as an option in the build that was ran for ng e2e it produced a protractor browser.baseUrl that ended in a / but now in Angular 8 it does not.

Meaning using a baseHref of /ext/ back in v7.1.3 made browser.baseUrl return http://localhost:4200/ext/ when running ng e2e but now in Angular 8 using a baseHref of /ext/ makes browser.baseUrl return http://localhost:4200/ext. That missing / at the end is a very important difference.

So the real problem here is that back in Angular 7.1.3 my e2e were passing while making use of the baseHref build flag and now they are not in latest Angular 8 version. The reason why they are not passing is because await browser.get('connect'); should navigate to http://localhost:4200/ext/connect but instead it is trying to navigate to http://localhost:4200/connect. This is because the browser.baseUrl is http://localhost:4200/ext and if you go into the code of Protractor you will see that it uses browser.baseUrl with the url.resolve(...) method. And url.resolve('http://localhost:4200/ext', 'connect'); returns 'http://localhost:4200/connect'.

Note: my Angular.json build has this for the baseHref: "baseHref": "/ext/"

🔬 Minimal Reproduction

  1. Create a new Angular 8 project
  2. Modify the angular.json file so that the basic build option uses a baseHref of /ext/
  3. Add routes, pages, and components so that http://localhost:4200/ext/connect is a valid page
  4. Update app.po.ts's navigateTo() method so that you use return brwoser.get('connect');
  5. Run ng e2e
  6. Observe that you get a 404 error because it tries to navigate to http://localhost:4200/connect instead of http://localhost:4200/ext/connect

🌍 Your Environment





     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.3.2
Node: 10.16.0
OS: linux x64
Angular: 8.2.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.2
@angular-devkit/build-angular      0.803.2
@angular-devkit/build-optimizer    0.803.2
@angular-devkit/build-webpack      0.803.2
@angular-devkit/core               8.3.2
@angular-devkit/schematics         8.3.2
@angular/cdk                       8.1.4
@angular/cli                       8.3.2
@angular/flex-layout               8.0.0-beta.27
@angular/material                  8.1.4
@angular/material-moment-adapter   8.1.4
@ngtools/webpack                   8.3.2
@schematics/angular                8.3.2
@schematics/update                 0.803.2
rxjs                               6.5.2
typescript                         3.5.3
webpack                            4.39.2
@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 Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants