Faking Dependencies in Angular Tests: Provider Overrides, vi.fn, ng-mocks, MSW and RouterTestingHarness
Fake what leaves the process, such as HTTP, time and browser APIs, and keep cheap dependencies like CartStore and the router real: a test that mocked everything missed a bug that emptied the cart before placing the order. On Bookstore's checkout and order detail pages we show provider overrides, vi.fn, vi.spyOn, hand-written fakes, child components with ng-mocks, network-level fakes with MSW 3 and RouterTestingHarness tests with the real routes, all with real runs.
14 Nov 2026
·
12 min
·
13