The Testing Module — Testing · NestJS

Build a class with its dependencies inside a test with Test.createTestingModule, provide the test's own values under its tokens, and take instances back out with get().

What you will learn

Read the theory for The Testing Module

All Testing lessons

All NestJS courses

loading types…

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