You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
spectator/projects/spectator/src/lib/spectator-routing/activated-route-stub.ts
Line 120 in defdedd
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
The text was updated successfully, but these errors were encountered: