Skip to content

Allow suppressing console.log output for successful tests in EDR networks #7737

@nikicat

Description

@nikicat

Describe the feature

When running tests, Solidity console.log() statements produce output regardless of test outcome. This clutters the terminal during successful test runs when debug output isn't needed.

Motivation:

I want to see console.log() output only when tests fail, keeping successful runs clean. Currently there's no way to conditionally control this from test runners or programmatically.

Proposed solution:

Expose the logger config option for EDR networks, allowing users to provide custom printLineFn/replaceLastLineFn handlers. This enables test frameworks to buffer or suppress output based on test results.

networks: {
  hardhat: {
    type: "edr-simulated",
    logger: {
      enabled: false,
      printLineFn: (line) => { /* custom handling */ },
      replaceLastLineFn: (line) => { /* custom handling */ },
    },
  },
}

Use case:

Test runners can buffer log output and only display it when a test fails, similar to how many test frameworks handle stdout.

Search terms

hide console.log in tests

Metadata

Metadata

Assignees

Labels

status:needs-more-infoThere's not enough information to start working on this issuestatus:needs-priorityPrioritisation is not complete

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions