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
git clone https://github.com/SimonTestNet/TourOfHeroes.git
cd TourOfHeroes
npm i
start
: Run the apptest
: Run the unit tests using Karmacoverage
: Run the tests and generate a coverage report
https://marketplace.visualstudio.com/items?itemName=SimonTest.simontest