Commit fc8dbaa
fix: use Minitest.after_run for report summary (#182)
* fix: use Minitest.after_run for report summary, not at_exit
Root cause: at_exit hooks run in LIFO order. Our at_exit was registered
after minitest's autorun, so it fired before tests finished — reporter
had total=0 because no assertions had been processed yet.
Fix: Use Minitest.after_run (runs after all tests complete) when
minitest is available, falling back to at_exit for RSpec/Cucumber.
Also remove screenshots&.clear from verify_screenshots! ensure block —
clearing now happens in registry.reset after notify_reporters, so
assertions are available for the reporter before being cleared.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: keep base image when screenshots differ for reporter
Previously, base_image_path was deleted after comparison when images
differed. This meant the HTML reporter couldn't show the baseline
image — it appeared as a broken "Base" alt text.
The base image is a VCS checkout that gets re-created on next run,
so keeping it has no side effects. The reporter now shows both
baseline and current images side-by-side.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: document .gitignore patterns for diff artifacts
- Add .gitignore block to README Quick Start
- Add .gitignore section to CI integration docs
- Add generated artifacts table to organization docs
- Add *.base.png to snap_diff:clean rake task
- Add *.base.png to test fixtures README
Files to gitignore: *.diff.png, *.base.png, *.diff.webp, *.base.webp,
snap_diff_report.html. Only commit baseline screenshots.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: register both at_exit and Minitest.after_run hooks
Always register at_exit (works for RSpec/Cucumber) AND additionally
Minitest.after_run when Minitest is loaded (correct ordering for
Minitest). The @Finalized guard in #finalize prevents double execution.
Previously the else branch meant RSpec/Cucumber users got no at_exit
hook when Minitest was also loaded in the same process.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: avoid double finalize call for Minitest
Restore if/else — Minitest.after_run when Minitest is loaded, at_exit
otherwise. Nobody runs Minitest and RSpec in the same process, so the
@Finalized double-execution guard is unnecessary overhead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: register framework-native hooks for RSpec and Cucumber
- Minitest: Minitest.after_run (runs after all tests)
- RSpec: RSpec.configure { |c| c.after(:suite) } (runs after suite)
- Cucumber/other: at_exit fallback
at_exit fires in LIFO order, so it runs BEFORE the test framework
finishes when registered after it. Framework-native hooks guarantee
correct ordering — reporter has data when finalize runs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: move finalize_reporters! to framework adapters
Extract finalize_reporters! into CapybaraScreenshotDiff module and
call it from each framework's native "after suite" hook:
- Minitest: Minitest.after_run
- RSpec: config.after(:suite)
- Cucumber: AfterAll
html.rb no longer detects frameworks — it just registers at_exit as
fallback for unknown frameworks. Each adapter owns its hook.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent d7153ab commit fc8dbaa
11 files changed
Lines changed: 78 additions & 22 deletions
File tree
- docs
- lib/capybara_screenshot_diff
- reporters
- test
- fixtures/images
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
14 | 29 | | |
15 | 30 | | |
16 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
35 | 59 | | |
36 | 60 | | |
37 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
| |||
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
61 | | - | |
62 | | - | |
63 | 59 | | |
64 | 60 | | |
65 | 61 | | |
| |||
135 | 131 | | |
136 | 132 | | |
137 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
138 | 145 | | |
139 | 146 | | |
140 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
0 commit comments