Files
cats.service.spec.ts
What you'll learn
- Build a Nest module inside a test with Test.createTestingModule and compile(), and explain why the hook that does it is async
- Provide a class's dependencies in the test, real or replaced, under the same tokens the application uses
- Retrieve instances from the compiled module with get(), by class and by token
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.
- one cat more than the capacity is acceptedcats/cats.service.ts
- creating a cat logs nothingcats/cats.service.ts
- the capacity is hard-coded to three, the config ignoredcats/cats.service.ts