Skip to content

silenceMessage does not work when shouldFailOnError=false #51

Description

@mstangret

Hi,
I wanted to use jest-fail-on-console as a silencer for the error logs that come from the third-party libraries but still allow errors and warnings to appear in logs and not break tests.
I tried this setup:

failOnConsole({
  shouldFailOnError: false,
  shouldFailOnWarn: false,
  silenceMessage: (errorMessage) => {
    if (
      /Warning: The current testing environment is not configured to support act/.test(
        errorMessage
      ) ||
      /Support for defaultProps will be removed from function components in a future major release/.test(
        errorMessage
      )
    ) {
      return true;
    }
    return false;
  }
});

However, the selected messages were not silenced unless I set shouldFailOnError to true but then other tests started failing on other console.errors.

Is this expected behavior?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions