Angular Unit Testing from the Trenches
summary
Practical, example-driven guide to unit testing Angular apps using the CLI with Karma and Jasmine, showing real code: component creation and DOM binding, TestBed + async + detectChanges for lifecycle and change detection, stubbing services versus Jasmine spies for Observable-driven ngOnInit, handling reactive-form gotchas (markAsDirty, debounce + tick), and HTTP tests with HTTPTestingController.flush to avoid hitting the backend. Routing checks use RouterTestingModule and a spy Location. Emphasis on fast, isolated, maintainable tests.
AI-written summary · about
chapters (26)
- 0:00Intro
- 8:43Best Practices
- 13:35Test Setup
- 14:05Testbed
- 15:34Simple Component
- 16:53Creating a Fixture
- 19:00Testing the DOM
- 20:23Recap
- 21:20Service Dependency
- 21:51stub
- 23:37spies
- 26:18tick
- 27:27stubs
- 28:21reactive forms
- 32:43dirty flag
- 35:21HTTP services
- 39:42HTTP testing
- 42:11Router testing
- 49:16Jasmine goodies
- 51:33Additional message
- 52:29Dont run this
- 52:55Release faster
- 53:17Look through the codebase
- 53:35Keep them fast
- 53:47Keep them simple
- 54:24Resources
related talks
52mAngular Testing: Do I Really Have to Do It?!
59mTechniques and practices for testing Angular 2
56mTechniques and practices for testing Angular
27mUnit Tests for Angular 2 Applications
19mTesting Best Practices for Angular Applications
32mTesting Angular apps
25mAngular + Jest: Testing Titbits
13mTesting Angular Components Fundamentals
