I am trying to set up Jest Unit Testing to my project, but I'm getting the following errors when trying to Unit Test:
How do I fix this issue?
CodePudding user response:
You need to add some sort of mock/provider for the ConfigService
. At the very least, this will make the test attempt to work.
{
provide: ConfigService,
useValue: {},
}
CodePudding user response:
When you initialise the AppConfigService
in test, you need to wire up the providers as well. If you dont need to mock you can directly provide the class in the providers list. If you need mocking, you can use the following dummy code. Refer here for nestjs testing documentation
providers: [
{
provide: AppConfigService,
useValue: createMock<AppConfigService>({
<method_name>: jest.fn(),
}),
},