Turn off logging while unit testing

See original GitHub issue

Hi. I’m running unit tests, I was unable to turn off logging.

Here is similar issue: https://github.com/nestjs/nest/issues/3246

I found that for regular run we can do the following:

  const app = await NestFactory.create(AppModule, {
    logger: ['error', 'warn'],
  });

but for unit tests, we cannot do so.

Maybe it’s worth adding a logger to option to DrivineModuleOptions ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

14reactions
alexgarbarevcommented, May 12, 2020

For tests, I’m using EmptyLogger

import { LoggerService } from '@nestjs/common';
export class EmptyLogger implements LoggerService {
  log(message: string): any {}
  error(message: string, trace: string): any {}
  warn(message: string): any {}
  debug(message: string): any {}
  verbose(message: string): any {}
}

Then in test:

const app = await Test.createTestingModule(module).compile();
app.useLogger(new EmptyLogger());
0reactions
myflowplcommented, May 14, 2020

@jasperblues thanks Jasper, that is very nice of you, lets do that after my PR’s will be merged 😉

I’m just migrating from OrientDB to Neo4j, and Drivine draw my attention while I was looking for solution in Node.js, so far it’s so cool, and only found minor bugs.

Today I’m trying to do my first deployment do testing servers with Neo4j+drivine, and hope to have time tomorrow to do some work on drivine

Good work 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I disable logging while running unit tests in Python ...
I've found that for tests within unittest or similar a framework, the most effective way to safely disable unwanted logging in unit tests...
Read more >
How can I disable logging while running unit tests in ... - Edureka
I am using a simple unit test based test runner to test my Django ... How can I disable logging while running unit...
Read more >
How To Disable Logging While Running Django Unit Tests?
How To Disable Logging While Running Django Unit Tests? ;.disable(logging.CRITICAL) ; import sys import logging if len(sys.argv) > 1 and sys.argv ...
Read more >
Logback - Disable logging in Unit Test - Mkyong.com
While the unit test is running in the IDE, the Logback is showing a lot of configuration or status like this :
Read more >
How can I disable logging while running unit tests in Python ...
I've found that for tests within unittest or similar a framework, the most effective way to safely disable unwanted logging in unit tests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found