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

Interop with RouterTestingHarness #383

Open
lacolaco opened this issue May 5, 2023 · 3 comments
Open

Interop with RouterTestingHarness #383

lacolaco opened this issue May 5, 2023 · 3 comments

Comments

@lacolaco
Copy link
Contributor

lacolaco commented May 5, 2023

Angular introduced RouterTestingHarness as a utility for testing a component that depends on the router.

RouterTestingHarness manages a root component to instantiate <router-outlet> and returns routed component by navigateByUrl(url, component) method. AFAIK, there is a conflict with the testing-library's render() approach. The responsibility for instantiating a ComponentFixture must be one or the other.

So, I can't suggest a specific solution yet, but I think that testing involving Router can be complex and this is precisely the kind of area that the Testing Library should help with. It would be desirable to provide a means to escape from MockRouter and MockActivatedRoute while still being able to use them with the Testing Library.

@lacolaco
Copy link
Contributor Author

lacolaco commented May 5, 2023

If we just want to query the generated DOM with the Testing Library, the within() function will solve this problem. Rather, I think it is more important to be able to take advantage of RouterTestingHarness while retaining the hiding and intuitive configuration of TestBed that render() achieves.

@timdeschryver
Copy link
Member

Hi @lacolaco sorry, I missed this issue.
While reading the introduction I was also thinking about this.
But, I'm still not sure how to proceed with it 😅

Do you have any ideas?
Or to ask the question differently, what use cases does it solve better than it does currently?

@lacolaco
Copy link
Contributor Author

@timdeschryver I don't have yet.

After I wrote this issue, Angular v16 supports router input binding withComponentInputs(), which allows us to pass data as inputs instead of Router params. Use-cases about component reactivity with router params I imagined are almost resolved by the feature.

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

2 participants