fix routed components#25
Conversation
commit: |
There was a problem hiding this comment.
Pull request overview
This PR updates the library’s render() helper to better support Angular Router-based tests by using RouterTestingHarness as the source of truth when routing is enabled, and by enabling withComponentInputBinding() by default (with an opt-out).
Changes:
- Update
render()to useRouterTestingHarnessforfixture,container/locator, andcomponentClassInstancewhenwithRoutingis enabled. - Enable
withComponentInputBinding()by default for routing tests; adddisableInputBindingto opt out. - Expand tests and README docs to cover route params and input binding via route data.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/pure.ts |
Implements routing-mode rendering via RouterTestingHarness, adds input binding toggle, and extends result shape. |
test/routed.test.ts |
Updates routing tests to use locator and adds coverage for route params + input binding behaviors. |
test/components/routed.component.ts |
Adds a routed test component that reads a route param via ActivatedRoute. |
README.md |
Updates code formatting and adds/updates routing documentation and examples. |
.changeset/plain-parrots-double.md |
Patch changeset describing the routing render “fix”. |
.changeset/eleven-jokes-burn.md |
Minor changeset describing the new input binding feature + opt-out. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
yjaaidi
left a comment
There was a problem hiding this comment.
🚀 LGTM. Good job buddy!
IMO, this highlights that render is doing too much and that we should either have a different API for router testing or just let users use the router harness directly.
For now, let's just keep this as is. We'll get back to this in the upcoming RFCs 😉
|
thanks for the review @yjaaidi ! |
Summary
Fix:
componentClassInstanceand fixture now refer to the activated route’s component when usingwithRouting.Feature: New
disableInputBindingoption in routing config to opt out of automatic route → input binding.Changes
Fix: Activated route component in render result (patch)
When rendering with
withRouting, the returnedcomponentClassInstanceandfixturenow match the component that Angular Router activated for the current route.Previously they could refer to a different component than the one rendered for the route. Assertions on
componentClassInstance(e.g. route params likeuserId) and fixture access now behave as expected.Feature:
disableInputBindingforwithRouting(minor)Routing tests use Angular’s
withComponentInputBinding()by default (route params, query params, and routedataare bound to component inputs).You can now pass
disableInputBinding: truein the routing config to disable this. The router is then provided withoutwithComponentInputBinding(), so components receive their default input values instead of values from the route. Useful when driving behavior only viaActivatedRouteor when you need to avoid automatic binding in specific tests.