Skip to content

test: add JSON round-trip and snapshot tests #163

@rocketman-code

Description

@rocketman-code

Context

Parent: #160

JSON field naming inconsistency (#149) was missed because tests check individual fields exist but never validate that struct field names match the serialized JSON schema end-to-end. Report types have to_json() and to_terminal() methods but no tests verify the full output shape.

Expected Behavior

Tests that serialize reports to JSON, deserialize into serde_json::Value, and assert the complete field structure matches a spec. Optionally, snapshot tests (via insta) that catch any unintentional output changes.

Scope

  • Add round-trip tests for every report type: TraceReport, ChainReport, CutReport, DiffReport, PackagesReport
  • Each test: build a report from a fixture, call to_json(), parse the JSON, assert all field names and types
  • Consider adding insta for snapshot testing of both JSON and terminal output
  • Assert field name consistency across report types (e.g., weight fields always use _bytes suffix)
  • Assert that to_terminal() and to_json() contain equivalent information

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priorityenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions