8000 Feature request: disable logs while testing with jest · Issue #1030 · aws-powertools/powertools-lambda-typescript · GitHub
[go: up one dir, main page]

Skip to content
Feature request: disable logs while testing with jest #1030
Closed
@IslamWahid

Description

@IslamWahid

Description of the feature request

Problem statement

While running jest I would like to suppress the logs on the console to make it readable and clean.

jest CLI is offering --silent option to prevent tests from printing messages through the console, but it doesn't seem to work with the logger.

Summary of the feature

Suggestions:

  • the logger is silenced when running in jest with --silent
  • the logger is disabled when running in the test environment or when NODE_ENV is a test
  • an option on the constructor to disable the logger

Code examples

jest --silent

Benefits for you and the wider AWS community

make the console readable and clean while running tests.

Describe alternatives you've considered

I have created a __mocks__/@aws-lambda-powertools/logger.ts with this setup

export const Logger = jest.fn().mockImplementation(() => {
  return {
    debug: () => jest.fn(),
    info: () => jest.fn(),
    error: () => jest.fn(),
  };
});

and this solves the issue.

Additional context

Related issues, RFCs

< 5709 div class="issue-timeline-loading-module__delaySkeletonLoad--qiw2o" data-testid="issue-timeline-loading">

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityloggerThis item relates to the Logger Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0