Accept query params in initialRoute property
jwbaart opened this issue ยท 9 comments
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
});
Good catch, I think this would be a great addition.
Do you want to create a PR for this @jwbaart ?
I'll see what I can manage :)
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.
Prepared a more extensive test case to test new functionality: main...jwbaart:angular-testing-library:main
Now on to the actual work :)
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.
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 :)
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.
A bit later on I used nx test testing-library --watchAll, works even better :)
Closed in #409