File tree Expand file tree Collapse file tree
lib/capybara_screenshot_diff/reporters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ jobs:
218218 SCREENSHOT_DRIVER : ${{ matrix.screenshot-driver }}
219219
220220 - uses : ./.github/actions/upload-screenshots
221- if : always ()
221+ if : failure ()
222222 with :
223223 name : screenshots-${{ matrix.capybara-driver }}-${{ matrix.screenshot-driver }}
224224
Original file line number Diff line number Diff line change @@ -19,8 +19,13 @@ require 'capybara_screenshot_diff/minitest'
1919```
2020
2121``` ruby
22- # test/system/homepage_test.rb
23- class HomepageTest < ActionDispatch ::SystemTestCase
22+ # test/application_system_test_case.rb (or test/system/homepage_test.rb)
23+ class ApplicationSystemTestCase < ActionDispatch ::SystemTestCase
24+ include CapybaraScreenshotDiff ::DSL
25+ include CapybaraScreenshotDiff ::Minitest ::Assertions
26+ end
27+
28+ class HomepageTest < ApplicationSystemTestCase
2429 test " homepage" do
2530 visit " /"
2631 screenshot " homepage" # First run: saves baseline. Next runs: compares.
@@ -42,8 +47,8 @@ When a screenshot differs, you get:
4247
4348| File | Description |
4449| ------| -------------|
45- | ` homepage.png ` | Current screenshot |
46- | ` homepage.base.png ` | Committed baseline |
50+ | ` homepage.png ` | Committed baseline (in version control) |
51+ | ` homepage.base.png ` | Runtime copy of baseline (for comparison) |
4752| ` homepage.diff.png ` | Visual diff with changes highlighted in red |
4853| ` homepage.heatmap.diff.png ` | Heatmap of pixel differences |
4954
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ test 'color threshold' do
215215end
216216```
217217
218- The difference is calculated as the eucledian distance. You can also set this globally:
218+ The difference is calculated as the euclidean distance. You can also set this globally:
219219
220220``` ruby
221221Capybara ::Screenshot ::Diff .color_distance_limit = 42
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def finalize
4343 end
4444
4545 write_report
46- true
46+ output_path
4747 end
4848
4949 def passed = total - failures . size
@@ -82,10 +82,10 @@ def failure_entry_for(name, compare)
8282 def relative_path ( path )
8383 return unless path
8484
85- pathname = Pathname . new ( path )
85+ pathname = Pathname . new ( path ) . expand_path
8686 return unless pathname . exist?
8787
88- pathname . relative_path_from ( @report_dir ) . to_s
88+ pathname . relative_path_from ( @report_dir . expand_path ) . to_s
8989 end
9090
9191 def write_report
@@ -98,13 +98,13 @@ def write_report
9898
9999unless CapybaraScreenshotDiff . reporters . any? ( CapybaraScreenshotDiff ::Reporters ::HTML )
100100 CapybaraScreenshotDiff . reporters << CapybaraScreenshotDiff ::Reporters ::HTML . new
101- end
102101
103- at_exit do
104- CapybaraScreenshotDiff . reporters . each do |reporter |
105- wrote = reporter . finalize
106- $stdout. puts "[snap_diff] HTML report: #{ reporter . output_path } " if wrote
107- rescue => e
108- warn "[snap_diff] Reporter #{ reporter . class } failed (#{ e . class } : #{ e . message } )" if ENV [ "DEBUG" ]
102+ at_exit do
103+ CapybaraScreenshotDiff . reporters . each do |reporter |
104+ result = reporter . finalize
105+ $stdout. puts "[snap_diff] HTML report: #{ result } " if result . is_a? ( Pathname )
106+ rescue => e
107+ warn "[snap_diff] Reporter #{ reporter . class } failed (#{ e . class } : #{ e . message } )" if ENV [ "DEBUG" ]
108+ end
109109 end
110110end
You can’t perform that action at this time.
0 commit comments