Testing Angular components becomes complex when they have child component dependencies, external libraries, or directives. Three approaches are compared: NO_ERRORS_SCHEMA (quick but hides template errors and reduces coverage), stub components (more control but requires manual maintenance), and NgMocks (recommended, using MockBuilder and MockRender to isolate components with minimal boilerplate). A practical scenario with ProductsComponent depending on ProductsListComponent and a Kendo UI listview illustrates the tradeoffs of each approach.
Table of contents
Scenario Copy link Link copied!Running Tests Copy link Link copied!NO_ERRORS_SCHEMA Copy link Link copied!Stub The Component Copy link Link copied!👀 The Hidden Price of Stub Copy link Link copied!Ng Mocks Copy link Link copied!Recap Copy link Link copied!Sort: