NestJS · Junior · Question 48 of 75

How do you create a testing module in Nest?

const moduleRef = await Test.createTestingModule({
  controllers: [UsersController],
  providers: [UsersService],
}).compile();

Explanation

The testing module builds a small DI container with just what the test needs.

Further reading

Problem with a question

NestJS · Junior · question 48

Test yourself

Take the NestJS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz