NG.VIII · Angular 22 practice question
A developer maintains a legacy spec file in Angular 22 that still depends on Zone-based change detection inside TestBed. Which provider must be registered in TestBed.configureTestingModule to enable Zone-based mode for that test?
Check answer and explanation
Correct answer: provideZoneChangeDetection()
Explanation
Registering provideZoneChangeDetection() in TestBed's providers explicitly switches the test environment to Zone-based change detection.
Common trap
provideNgZone() sounds plausible because NgZone is the core Angular service, but Angular does not provide a function with that name for configuring change detection. provideLegacyChangeDetection() sounds like a migration helper for older behavior, but the actual Angular API is provideZoneChangeDetection().
Source: Angular docs: Angular without ZoneJS (Zoneless) — Using Zoneless in `TestBed`
Checked against the cited text on 2026-11-25.