Your First Test — Testing · NestJS

Write unit tests for a plain service: the shape of a test, the matchers that say what you expect, and the bugs a test is worth nothing without catching.

What you will learn

Read the theory for Your First Test

All Testing lessons

All NestJS courses

loading types…

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