codejump

Unit Testing Basics

Preview — 3 of 10 questions

Which API from @nestjs/testing do you use to assemble a module for testing a service and its dependencies?

ANestFactory.create()
Bjest.createModule()
Cnew TestingModule()
DTest.createTestingModule({ providers })

After Test.createTestingModule({...}), what does await builder.compile() return?

AThe raw metadata object you passed in
BA Jest mock of the module
CA running HTTP server
DA TestingModule instance with an initialized DI container you can pull providers from

How do you obtain the UserService instance from a compiled TestingModule for a standard singleton provider?

AmoduleRef.get(UserService)
BmoduleRef.find(UserService)
CmoduleRef.inject(UserService)
DmoduleRef.provider(UserService)

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.