Jump.CredoChecks.AvoidLoggerConfigureInTest (Jump.CredoChecks v0.3.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

Ensures that tests don't call Logger.configure/1.

Calling Logger.configure/1 in tests affects the global logger configuration for all concurrent test processes, which can introduce unexpected log spam and create flaky tests.

Instead of trying to test for particular log messages, consider testing for results that indicate the right things happened. For example, the right database records were created, the expected side effects occurred, the function returned the expected value, etc.

If the business outcome that goes along with the message can't be tested for, it's a code smell---you should consider refactoring the code to make it testable.

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.