@ogma/nestjs-module
: How to test controllers/services?
#1538
Answered
by
jmcdo29
tukusejssirs
asked this question in
Q&A
-
In const app = await Test.createTestingModule({
providers: [
ConfigService,
OgmaService,
GatewayService,
{
provide: 'OGMA_INSTANCE',
useFactory: () => new Ogma({
logLevel: 'ALL' as const,
color: true,
}),
},
{
provide: 'OGMA_CONTEXT',
useValue: 'Test_context',
},
{
provide: 'OGMA_SERVICE:GatewayService',
useValue: 'GatewayService',
},
{
provide: 'OGMA_TRACE_METHOD_OPTION',
useValue: 'fine',
},
],
}).compile() It works, but is it the correct way to mock Thanks! 🙏 |
Beta Was this translation helpful? Give feedback.
Answered by
jmcdo29
Feb 14, 2023
Replies: 1 comment 4 replies
-
If you use {
provide: OgmaService,
useValue: {
log: jest.fn(),
debug: jest.fn(),
...etc
}
} If you use |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
jmcdo29
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use
OgmaService
directly you can just use a simple custom provider:If you use
@OgmaLogger()
you can do the same as above but usecreateProviderToken()
instead ofOgmaService