Skip to content

Accept query params in initialRoute property #406

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
jwbaart opened this issue Aug 14, 2023 · 9 comments
Closed

Accept query params in initialRoute property #406

jwbaart opened this issue Aug 14, 2023 · 9 comments

Comments

@jwbaart
Copy link
Contributor

jwbaart commented Aug 14, 2023

We're using query params to configure our feature when loading and have a redirect in place when missing to set those. When using the initalRoute property, to prevent the redirect, query params aren't accepted(link).
Navigation with query params is already available in a separate function.

it('allows initially rendering a specific route with query parameters', async () => {
    const initialRoute = 'initial-route?param=query';
    const routes = [
      { path: initialRoute, component: FixtureComponent },
    ];
    await render(RouterFixtureComponent, {
      initialRoute,
      routes,
    });

    const router = TestBed.inject(Router);

    expect(router.url).toEqual(initialRoute);
    // could also be implemented by actually reading the params from ActivatedRoute but is more complex and the above does the same
  });
@timdeschryver
Copy link
Member

Good catch, I think this would be a great addition.
Do you want to create a PR for this @jwbaart ?

@jwbaart
Copy link
Contributor Author

jwbaart commented Aug 15, 2023

I'll see what I can manage :)

@timdeschryver
Copy link
Member

You don't have to feel obligated, and you can take your time with this.
I was only asking it to prevent that we're working on it at the same time.

@jwbaart
Copy link
Contributor Author

jwbaart commented Aug 16, 2023

Prepared a more extensive test case to test new functionality: main...jwbaart:angular-testing-library:main
Now on to the actual work :)

@jwbaart
Copy link
Contributor Author

jwbaart commented Aug 16, 2023

Am I correct I couldn't find test watch functionality? I now monkey patched it with custom npm script("test:watch": "jest --watchAll") but expected it to already be present.

@jwbaart
Copy link
Contributor Author

jwbaart commented Aug 16, 2023

projects/testing-library/tests/integrations/ng-mocks.spec.ts was logging multiple missing ngIf imports logs, fixed this with: 82b232c. Mostly to make the jest result logging more readable :)

@timdeschryver
Copy link
Member

Am I correct I couldn't find test watch functionality? I now monkey patched it with custom npm script("test:watch": "jest --watchAll") but expected it to already be present.

😅 It seems like it yea.
You should be able to add a --watch flag to the existing test script, feel free to add it as test:watch if you want.

@jwbaart
Copy link
Contributor Author

jwbaart commented Aug 16, 2023

A bit later on I used nx test testing-library --watchAll, works even better :)

@timdeschryver
Copy link
Member

Closed in #409

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