Files
shelter.e2e-spec.ts
What you'll learn
- Boot the whole service in a test, configure it as main.ts does, and give every test a fresh application and database
- Write a helper that signs in, and test authorization by trying every route as nobody, as an adopter and as staff
- Assert what a response must not contain as well as what it must
- Check a transaction's rollback by reading the data back after a refusal, not only the refusal's status
Press Run tests to start the app. Its log appears here.Tests
- test/shelter.e2e-spec.tsrun to see its tests
Bugs your tests must catch
Each of these replaces one file with a buggy version and runs your tests again. A bug is caught when at least one test fails against it. Tests that pass whatever the code does are not tests.
- an adopter can add cats: @Roles('staff') is gone from POST /catscats/cats.controller.ts
- responses carry the password hash: @Exclude() is goneusers/user.entity.ts
- an adopted cat can be adopted againadoptions/adoptions.service.ts
- the limit is checked after the commit, so a refused adoption keeps the catadoptions/adoptions.service.ts