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

Spectator routing API (setRouteParams and others) trigger value emission for all ActivatedRoute properties regardless of API call made #666

Open
antonborisoff opened this issue Aug 25, 2024 · 1 comment

Comments

@antonborisoff
Copy link

antonborisoff commented Aug 25, 2024

Is this a regression?

No

Description

When we use Spectator routing API to manipulate URL (setRouteParam and others) it makes ActivatedRouteStub to emit values for all properties (params, queryParams, etc.) instead of emitting values only for target properties (setRouteParam -> params emits value, etc.)
Such behaviour could lead to tests passing even when functionality under test is broken. See the link to such an example attached.

The issue is caused by ActivatedRouteStub triggerNavigation implementation:


Compare it with what Angular actually does: https://github.com/angular/angular/blob/7a99815146eb78074aa3ed6db73c6e87042df692/packages/router/src/router_state.ts#L483

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-testing-spectator-bvdhbk?file=app%2Fhello.component.spec.ts

The app contains a bug (see component code), but the test for the component passes due to describe Spectator API issue.

Actual Result: the test in the link passes
Expected Result: the test fails; the test passes when we fix the issue in the component

It would be ideal if ActivatedRouteStub emits values only when they change like Angular ActivatedRoute does.

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No

Copy link

stackblitz bot commented Aug 25, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant