Skip to content

bug(forge test): JSON output should consistently adhere to verbosity flags #8735

Open
@bowd

Description

@bowd

Component

Forge

Describe the feature you would like

It would be useful if the --json output of forge test would also contain the call traces and console.log output that the normal output contains.

Currently --json output's structure doesn't change if I increase verbosity, it looks like this:

{
  "test/oracles/ChainlinkRelayerFactory.t.sol:ChainlinkRelayerFactoryTest_deployRelayer": {
    "duration": "1ms 893us 708ns",
    "test_results": {
      "test_revertsWhenDeployingToAddressWithCode()": {
        "status": "Success",
        "reason": null,
        "counterexample": null,
        "logs": [
          { ... },
          { ... },
        ],
        "kind": {
          "Unit": {
            "gas": 104634
          }
        },
        "labeled_addresses": { ... },
        "duration": {
          "secs": 0,
          "nanos": 277375
        },
        "breakpoints": {}
      }
    },
    "warnings": []
  }
}

Additional context

I've been playing around with this idea of building an interactive testing environment for forge.

I find my self a lot of the time copy-pasting long test names in order to narrow down when I'm debugging or refactoring. I'd like a bit of UI that helps me by keeping track of failed tests and letting me dive in and out of the filtering options. I'd also like auto toggle verbosity on when I'm running a single test. And in the verbose mode have more control over the trace, collapsing longer sections, prettier structs, filtering some vm related logs, toggling setUp, toggling all calls to a certain function, etc. I think working with the traces is amazing but the UX can be improved a lot. I find this especially true when doing more complex fork test scenarios where there's a lot of stuff going on. And having a way to parse the forge test output with full verbosity would be amazing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-forgeCommand: forgeCmd-forge-testCommand: forge testP-normalPriority: normalT-bugType: bugfirst issueA good way to start contributing

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions