Skip to content

Testing navigation with query params #91

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

Closed
skolldev opened this issue Apr 16, 2020 · 4 comments · Fixed by #93
Closed

Testing navigation with query params #91

skolldev opened this issue Apr 16, 2020 · 4 comments · Fixed by #93
Labels
bug Something isn't working released

Comments

@skolldev
Copy link

Hi,

Versions:

"@angular/router": "~9.1.0",
"@testing-library/angular": "^9.1.0",
"@testing-library/jest-dom": "^5.1.1",

I'm trying to test a component that has behaviour based on its query params.
I have my routing configuration:

routes: [
    { path: 'register', component: RegistrationComponent }
]

Then, in the test im trying to navigate to it with a query param:

await navigate('register?token=abc');

However, I'm getting the following error:
Cannot match any routes. URL Segment: 'register%3Ftoken%3Dabc'

Is there a better way to test it? Or am I getting something wrong?

@timdeschryver
Copy link
Member

Hi @skolldev, could it be that there's a missing base path?
See https://github.com/testing-library/angular-testing-library/blob/master/src/app/examples/09-router.spec.ts#L76-L79 for an example.
I will also try to test it with a query param later today/tomorrow

@timdeschryver
Copy link
Member

I was able to reproduce it in the example apps, will try to provide a fix for this ASAP. Thanks for creating the issue

@timdeschryver timdeschryver added the bug Something isn't working label Apr 16, 2020
timdeschryver added a commit that referenced this issue Apr 16, 2020
@skolldev
Copy link
Author

Wow Tim, that was super quick! Thanks for your help :)

@timdeschryver
Copy link
Member

🎉 This issue has been resolved in version 9.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants