'nestjs logging service for JEST

I have a problem to view log inside nestjs when execute in Jest. I can setup to see logger when running nestjs fine But when running via Jest. The logger is not print out on screen.

Below is the code that using to setup testing module.

const module: TestingModule = await Test.createTestingModule({
  imports: [HttpModule, ScheduleModule.forRoot()],
  controllers: [ExampleController],
  providers: [ExampleService, Logger],
}).compile();

module.useLogger(['error', 'warn', 'log', 'debug', 'verbose']);

And in ExampleController

import { Controller, Get, Logger } from '@nestjs/common';

@Controller('example')
export class ExampleController {
  private readonly logger = new Logger(ExampleController.name);

  @Get()
  getExample(): string {
    this.logger.debug('example');
    return 'example';
  }
}

This debug message is not shown when running on Jest.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source