Skip to content

Commit 2bb7b97

Browse files
pftgclaude
andcommitted
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>
1 parent b2dd1a8 commit 2bb7b97

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

lib/capybara_screenshot_diff/screenshot_assertion.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ def self.assert_image_not_changed(backtrace, name, comparison)
5656
# Cleanup after comparisons
5757
if !result && comparison.base_image_path.exist?
5858
FileUtils.mv(comparison.base_image_path, comparison.image_path, force: true)
59-
elsif !comparison.dimensions_changed?
60-
FileUtils.rm_rf(comparison.base_image_path)
6159
end
6260

6361
return unless result

test/unit/dsl_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ def assert_no_screenshot_jobs_scheduled
152152
assert_not comparison.base_image_path.exist?
153153
end
154154

155-
test "#assert_image_not_changed cleans up base image when images differ" do
155+
test "#assert_image_not_changed keeps base image when images differ" do
156156
comparison = make_comparison(:a, :b)
157157
assert_image_not_changed(["my_test.rb:42"], "name", comparison)
158-
assert_not comparison.base_image_path.exist?
158+
assert comparison.base_image_path.exist?, "base image should be kept for reporter"
159159
end
160160

161161
private

0 commit comments

Comments
 (0)