Skip to content

The summary line is invisible by default — it ships inside the HTML reporter #269

Description

@pftg

Found while writing the 2.0.0 CHANGELOG (#268), verified independently.

The problem

SnapDiff::Reporting.register appears exactly once in the gem, at lib/snap_diff/reporters/html.rb:140. So the honest summary line comes bundled with the HTML report. A user who follows our documented Rails setup gets neither:

$ ruby -e 'require "snap_diff/integrations/minitest"; puts SnapDiff::Reporting.reporters.size'
0

lib/snap_diff/integrations/minitest.rb requires dsl, screenshot_assertion and reporting — never reporters/html. So out of the box there is no reporter, and therefore no summary.

Why this matters more than a missing feature

The summary line exists specifically to catch the failure modes no per-assertion rule can see. Of the three routes to a green suite that compared nothing, two — rake test running zero system tests, and an inherited GIT_DIR redirecting every baseline lookup — never reach an assertion at all. 0 verified is the only signal for either.

Shipping that signal behind an opt-in require means the default configuration is the one that cannot detect the problem the signal was built for.

A 1.15.1 user upgrading also sees the headline improvement of #261 as simply absent.

The distinction to make

The counting is core honesty; the HTML file is a feature. They are currently one object.

  • The summary line is stdout, costs nothing, and should always print.
  • Writing snap_diff_report.html creates a file on disk — reasonable to keep opt-in, since turning it on for everyone changes what a test run leaves behind.

Proposed: SnapDiff::Reporting owns the counting and prints the summary unconditionally; Reporters::HTML keeps the report file and stays opt-in. Today the second one owns both.

Checklist

  • Move the counting and the summary line out of Reporters::HTML into Reporting
  • The summary prints with no reporter registered — guard it as the USER's code (their require, their assertion, a real process)
  • 0 verified still shouts (the NOTHING WAS VERIFIED case, added in feat: the summary line counts what was verified, not just what was compared #261)
  • Counts stay correct under fork-parallel merge (fix: the HTML report survives Rails' fork-parallel test runs (#258) #266) — Reporting already owns the fragment merge, so this should simplify rather than complicate it
  • HTML report remains opt-in and unchanged; no new file appears for users who did not ask for one
  • Do not double-print when the HTML reporter IS registered
  • Mutation-check each guard; a mutation that reds nothing is a finding

Related, same root cause

docs/reporters.md documents record/finalize/summary as the custom-reporter contract. If counting moves to Reporting, that contract gets simpler — a custom reporter stops being responsible for telling the truth about what ran.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions