Files
cats.service.spec.ts
What you'll learn
- Structure a test with describe, it and beforeEach, and read its result
- Choose between toBe, toEqual, toHaveLength and toThrow, and know why toThrow takes a function
- Judge a test by the bugs it catches, not by whether it passes
Press Run tests to start the app. Its log appears here.Tests
- cats/cats.service.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.
- every cat gets id 1cats/cats.service.ts
- findOne returns undefined instead of throwingcats/cats.service.ts
- remove returns the cat but keeps itcats/cats.service.ts
- cats are listed newest firstcats/cats.service.ts