CodeZettaInterview Hub

Angular · Testing · Tech Lead · Live Coding

How do you test route guards?

Short Interview Answer

Call the guard function with mock routers/auth state and assert boolean/UrlTree results.

Detailed Explanation

With functional guards, inject deps via TestBed.runInInjectionContext. Cover authorized and unauthorized paths.

Did you know this answer?