Disable winston logging when running unit tests?

前端 未结 7 1077
暗喜
暗喜 2021-02-05 03:18

Can Winston logging be selectively disabled when executing unit tests of a node module?

Ideally, I\'d like to have logging for informational and debug purposes when the

7条回答
  •  抹茶落季
    2021-02-05 03:34

    Create a logger:

    const logger = createLogger({
        level: "info",
        format: format.json(),
        transports: []
    });
    

    Silence all logging:

    logger.transports.forEach((t) => (t.silent = true));
    

提交回复
热议问题