Angular components - unit testing
summary
Example Angular app (spacefleet + spaceship) gets unit-tested with Angular CLI default stack: TestBed.configureTestingModule and fixture APIs, running tests with ng test under Jasmine/Karma. Mocks replace child components and a mocked spaceship service returns two ships (Viper, Raptor). Tests assert component instantiation, fleet name rendering, two child spaceship elements, and that clicking the create button calls spaceshipService.createShip. All tests execute in-browser with manual detectChanges and pass.
AI-written summary · about
chapters (6)
- 0:00Introduction
- 1:10Why components are special
- 2:15Testing tools
- 3:05Dependencies
- 4:40Mocking
- 5:55Presentation
related talks
56mAngular Unit Testing from the Trenches
56mTechniques and practices for testing Angular
59mTechniques and practices for testing Angular 2
27mUnit Tests for Angular 2 Applications
13mTesting Angular Components Fundamentals
32mTesting Angular apps
25mAngular + Jest: Testing Titbits
58mTestable Architecture in Angular
