NestJS · Junior · Question 49 of 75
How do you replace a real service with a mock in a Nest test?
- 1Edit the service file during the test
- 2Delete the provider from the module
- ✓Correct answer:
.overrideProvider(UsersService).useValue(mockService)on the testing module builder
Explanation
You can also register { provide: UsersService, useValue: mock } directly in providers.