Tour of Heros (Tested)
February 5, 2021 ยท View on GitHub
This is the Tour of Heroes example app fully tested using best practices. It can be used to learn better ways to test Angular components and services or as reference guide.
These are some of the concepts showcased in this repo:
- Isolating the components
- Stubbing dependencies
- Isolating tests
- Avoiding global variables
- Testing the UI of the components, not the code
- Reset components and dependencies before using them
- Faking the clock instead of delaying tests
- Using Jasmine blocks to organize the tests
For more information on testing each individual component check these articles:
- MessagesComponent
- DashboardComponent
- HeroDetailComponent
- HeroSearchComponent
- HeroesComponent
- MessageService
- HeroService
Get the Code
git clone https://github.com/SimonTestNet/TourOfHeroes.git
cd TourOfHeroes
npm i
npm scripts
start: Run the apptest: Run the unit tests using Karmacoverage: Run the tests and generate a coverage report
Test Generator
https://marketplace.visualstudio.com/items?itemName=SimonTest.simontest