Angular · Senior · Question 48 of 75
How do you test guards and routed components together?
- ✓Correct answer: With
RouterTestingHarness, navigating to a URL and checking the activated component - 2By calling the guard function with
nullarguments - 3Routing can only be tested end-to-end in a browser
Explanation
const harness = await RouterTestingHarness.create(); await harness.navigateByUrl('/admin'); runs real guards and resolvers with provideRouter(routes) in the test.