A practical guide to using Angular Testing Library for component testing. Covers the core philosophy of testing from the user's perspective rather than implementation details. Walks through rendering components, using queries (getByText, getByLabelText), firing events (click, input, userEvent.type), setting @Input/@Output properties, and testing container components with stubbed services. Also includes tips on preferring longer single tests over multiple small ones, avoiding beforeEach in favor of setup functions, and using complementary tools like @testing-library/jest-dom and Cypress Testing Library.
Table of contents
The Angular Testing LibraryGetting StartedOur first testQueriesSetting @Input() and @Output() propertiesEventsWorking with containers and componentsA couple of tips for writing testsExample code6 Impressions