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

feat(platform-browser): include Location mocks into testing environment by default #47413

Closed
wants to merge 1 commit into from

Conversation

AndrewKushnir
Copy link
Contributor

Currently, the Location and LocationStrategy mocks are added by the Router's testing module (the RouterTestingModule). However, the Location and LocationStrategy abstractions are parts of the @angular/common package and can be used outside of the Router logic to interact with the location.

This PR adds the Location and LocationStrategy mocks into the BrowserTestingModule NgModule, which is used for environment setup in TestBed. Adding the mocks there has 2 main advantages:

  • Location and LocationStrategy mocks will always be setup when you use TestBed (note: if you provide location mocks in the TestBed.configureTestingModule, custom mocks would still be used), which would cover cases when the Location is used in apps code directly.
  • The Router would not need to provide the mocks for abstractions that belong to the different package (@angular/common), which should help simplify the standalone Router APIs for testing.

PR Type

What kind of change does this PR introduce?

  • Feature

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added state: WIP area: common Issues related to APIs in the @angular/common package target: major This PR is targeted for the next major release labels Sep 13, 2022
@ngbot ngbot bot added this to the Backlog milestone Sep 13, 2022
…nt by default

Currently, the `Location` and `LocationStrategy` mocks are added by the Router's testing module (the `RouterTestingModule`). However, the `Location` and `LocationStrategy` abstractions are parts of the `@angular/common` package and can be used outside of the Router logic to interact with the location.

This PR adds the `Location` and `LocationStrategy` mocks into the `BrowserTestingModule` NgModule, which is used for environment setup in TestBed. Adding the mocks there has 2 main advantages:

- `Location` and `LocationStrategy` mocks will always be setup when you use TestBed (note: if you provide location mocks in the TestBed.configureTestingModule, custom mocks would still be used), which would cover cases when the `Location` is used in apps code directly.
- The Router would not need to provide the mocks for abstractions that belong to the different package (`@angular/common`), which should help simplify the standalone Router APIs for testing.
@angular-robot angular-robot bot added the feature Issue that requests a new feature label Oct 5, 2022
@AndrewKushnir
Copy link
Contributor Author

Presubmit.

@AndrewKushnir
Copy link
Contributor Author

Closing in favor of #47674.

@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 Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: common Issues related to APIs in the @angular/common package feature Issue that requests a new feature state: WIP target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant