Skip to content

Commit 6c5840f

Browse files
pftgclaude
andcommitted
feat: default blur_active_element and hide_caret to true
Every real-world app enables these to prevent flaky screenshots from blinking cursors and focused input elements. Making them default saves boilerplate and matches universal usage pattern. Users can still set false to opt out. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c078dec commit 6c5840f

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/capybara_screenshot_diff.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ module Capybara
2727
module Screenshot
2828
mattr_accessor :add_driver_path
2929
mattr_accessor :add_os_path
30-
mattr_accessor :blur_active_element
30+
mattr_accessor(:blur_active_element) { true }
3131
mattr_accessor :enabled
32-
mattr_accessor :hide_caret
32+
mattr_accessor(:hide_caret) { true }
3333
mattr_reader(:root) { (defined?(Rails) && defined?(Rails.root) && Rails.root) || Pathname(".").expand_path }
3434
mattr_accessor :stability_time_limit
3535
mattr_accessor :window_size

test/test_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ class ActiveSupport::TestCase
4040
self.file_fixture_path = Pathname.new(File.expand_path("fixtures", __dir__))
4141

4242
setup do
43-
# Tests create new screenshots — don't fail on missing baselines
4443
@_orig_fail_if_new = Capybara::Screenshot::Diff.fail_if_new
44+
@_orig_blur = Capybara::Screenshot.blur_active_element
45+
@_orig_hide_caret = Capybara::Screenshot.hide_caret
46+
4547
Capybara::Screenshot::Diff.fail_if_new = false
48+
Capybara::Screenshot.blur_active_element = false
49+
Capybara::Screenshot.hide_caret = false
4650
end
4751

4852
teardown do
4953
Capybara::Screenshot::Diff.fail_if_new = @_orig_fail_if_new
54+
Capybara::Screenshot.blur_active_element = @_orig_blur
55+
Capybara::Screenshot.hide_caret = @_orig_hide_caret
5056
CapybaraScreenshotDiff::SnapManager.cleanup! unless persist_comparisons?
5157
end
5258

0 commit comments

Comments
 (0)