This project was generated with Angular CLI version 1.1.2.
It uses:
It shows how to:
- take advantage of the fakeAsync testing approach
- fix timing issues by sharing the same time between the zone and RxJs
- inject your own schedulers in order to test RxJs events
Since the Google Books API need to be "proxied" via proxy.conf file you need to start the server by issuing
npm run start
.
Nevertheless, Google Books API might or might not work without the API key. The API key is secret and therefore not under version control. A custom environment file is being used to add the Google API key:
- create the file
./src/environments/environment.custom.ts
- add this content:
export const environment = {
production: false,
GOOGLE_BOOKS_API_KEY: 'your_api_key'
};
- execute
npm run start-custom
execute the tests as usual: ng test
src/app/internals/fake-zone-and-test-scheduler-test.spec.ts
: helps to understand thefakeAsync
utility and demonstrates the usage of the own schedulersrc/app/internals/async-zone-time-in-sync-keeper.utils.ts
: introduces the "in-sync-keeper" utility for fixingfakeAsync
timing issuessrc/app/internals/spying-test-scheduler.ts
: custom RxJs test schedulersrc/app/internals/monkey-patch-scheduler.utils.ts
: injects the spying test scheduler for testing purposes**/*.spec.ts
: the actual usage of the testing utilities mentioned above