I have a component with the following route configuration:
{
path: "offers",
loadComponent: () => import('./offer-details/containers/offer-details/offer-details.component').then((m) => m.OfferDetailsComponent),
data: { isOffer: true }
}
I am using the isOffer state to conditionally display some components. There is a search component where the search input is merged with the route, for example, offers?filter=test. I listen to queryParamsto make a request and load new offers.
During integration tests, I want to navigate to the route with queryParams before creating the component instance to process queryParams in ngOnInit.
I have tried several approaches but haven’t been successful. Here’s what I’ve tried so far:
Using RouterTestingModule and injecting the Router to navigate to offers?filter=test, but queryParams is undefined.
router.navigate(['/offers'],
{
queryParams: { filter: 'test' }
}
);
Could you help me and give me any advice or solution how to solve this problem?