Skip to content

Testing navigation with query params #91

Closed
@skolldev

Description

@skolldev

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions