summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2024-06-24 18:23:03 +0200
committerClaire <claire.github-309c@sitedethib.com>2024-06-25 09:54:28 +0200
commitb0abca0bdce63e5b6c88a35125a5dfc1931c780d (patch)
tree1de25ed7e465cc05b57591eed96f5412b90b6e5b /spec
parent8827cd597e695c0368dfdce582755eda7f667272 (diff)
Additional logging for flaky end-to-end teststests/flaky-tests-performance-logs
Diffstat (limited to 'spec')
-rw-r--r--spec/support/capybara.rb1
-rw-r--r--spec/support/javascript_errors.rb11
2 files changed, 12 insertions, 0 deletions
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index be1378ffac7..c456cf99645 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -14,6 +14,7 @@ Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument '--headless=new'
options.add_argument '--window-size=1680,1050'
+ options.add_option('goog:loggingPrefs', { performance: 'ALL' })
Capybara::Selenium::Driver.new(
app,
diff --git a/spec/support/javascript_errors.rb b/spec/support/javascript_errors.rb
index 28a43b3b8a5..5806f11c1da 100644
--- a/spec/support/javascript_errors.rb
+++ b/spec/support/javascript_errors.rb
@@ -2,7 +2,18 @@
RSpec.configure do |config|
config.after(:each, :js, type: :system) do
+ performance_logs = page.driver.browser.logs.get(:performance).map(&:message)
errors = page.driver.browser.logs.get(:browser)
+
+ # Save performance logs to capybara directory for further inspection
+ if performance_logs.present? && errors.present? && errors.any? { |error| error.level == 'SEVERE' }
+ path = File.join(Capybara.save_path, "performance-log-#{SecureRandom.hex(10)}.json")
+
+ warn "WARN: saving performance logs to #{path}"
+
+ File.write(path, "[#{performance_logs.join(',')}]")
+ end
+
if errors.present?
aggregate_failures 'javascript errrors' do
errors.each do |error|