2024-01-12 10:12:31 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
2024-05-10 14:36:09 +02:00
|
|
|
config.after(:each, :js, type: :system) do
|
2024-06-24 18:23:03 +02:00
|
|
|
performance_logs = page.driver.browser.logs.get(:performance).map(&:message)
|
2024-01-12 10:12:31 +01:00
|
|
|
errors = page.driver.browser.logs.get(:browser)
|
2024-06-24 18:23:03 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2024-01-12 10:12:31 +01:00
|
|
|
if errors.present?
|
|
|
|
aggregate_failures 'javascript errrors' do
|
|
|
|
errors.each do |error|
|
|
|
|
expect(error.level).to_not eq('SEVERE'), error.message
|
|
|
|
next unless error.level == 'WARNING'
|
|
|
|
|
2024-01-15 22:26:11 +01:00
|
|
|
warn 'WARN: javascript warning'
|
|
|
|
warn error.message
|
2024-01-12 10:12:31 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|