Skip to content

Commit 3b90667

Browse files
authored
fix: reuse Capybara chrome instance for lighthouse audits (#616)
Right now we actually spin up a whole new instance of Chrome when running lighthouse tests which besides being costly also means that none of our presetup work such as logging users in happens 😬
1 parent 6f51d36 commit 3b90667

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

variants/accessibility/spec/rails_helper.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
REQUIRE
66
end
77

8-
insert_into_file! "spec/rails_helper.rb", after: /# Add other Chrome arguments here\n/ do
8+
insert_into_file! "spec/rails_helper.rb", before: /# Add other Chrome arguments here\n/ do
99
<<~OPTIONS
10-
# Lighthouse Matcher options
10+
# have lighthouse use the instance of Chrome launched by Capybara, rather than
11+
# starting its own instance - this is important as otherwise setup work such
12+
# signing in as a user to access authenticated pages won't work properly
1113
options.add_argument("--remote-debugging-port=9222")
12-
Lighthouse::Matchers.chrome_flags = %w[headless=new no-sandbox]
14+
Lighthouse::Matchers.remote_debugging_port = 9222
1315
Lighthouse::Matchers.results_directory = Rails.root.join("tmp/lighthouse")
1416
OPTIONS
1517
end

0 commit comments

Comments
 (0)