A platform for community discussion. Free, open, simple.
DEV: Print system test logs with other test metadata (#19637)
David Taylord4d9d60a5f3b
diff --git a/lib/turbo_tests/json_rows_formatter.rb b/lib/turbo_tests/json_rows_formatter.rbindex f6a424a63a9..1c2e78a0839 100644--- a/lib/turbo_tests/json_rows_formatter.rb+++ b/lib/turbo_tests/json_rows_formatter.rb@@ -57,7 +57,8 @@ module TurboTestsshared_group_inclusion_backtrace:example.metadata[:shared_group_inclusion_backtrace]- .map(&method(:stack_frame_to_json))+ .map(&method(:stack_frame_to_json)),+ extra_failure_lines: example.metadata[:extra_failure_lines]},location_rerun_argument: example.location_rerun_argument}diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 10744cdfde1..5aa35a947bc 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -379,14 +379,17 @@ RSpec.configure do |config|endconfig.after(:each, type: :system) do |example|+ lines = RSpec.current_example.metadata[:extra_failure_lines]+# This is disabled by default because it is super verbose,# if you really need to dig into how selenium is communicating# for system tests then enable it.if ENV["SELENIUM_VERBOSE_DRIVER_LOGS"]- puts "~~~~~~ DRIVER LOGS: ~~~~~~~"+ lines << "~~~~~~~ DRIVER LOGS ~~~~~~~"page.driver.browser.logs.get(:driver).each do |log|- puts log.message+ lines << log.messageend+ lines << "~~~~~ END DRIVER LOGS ~~~~~"end# Recommended that this is not disabled, since it makes debugging@@ -394,20 +397,28 @@ RSpec.configure do |config|if ENV["SELENIUM_DISABLE_VERBOSE_JS_LOGS"].blank?if example.exceptionskip_js_errors = false+if example.exception.kind_of?(RSpec::Core::MultipleExceptionError)- puts "~~~~~~ SYSTEM TEST ERRORS: ~~~~~~~"+ lines << "~~~~~~~ SYSTEM TEST ERRORS ~~~~~~~"example.exception.all_exceptions.each do |ex|- puts ex.message+ lines << ex.messageend+ lines << "~~~~~ END SYSTEM TEST ERRORS ~~~~~"skip_js_errors = trueendif !skip_js_errors- puts "~~~~~~ JS ERRORS: ~~~~~~~"- page.driver.browser.logs.get(:browser).each do |log|- puts log.message+ lines << "~~~~~~~ JS LOGS ~~~~~~~"+ logs = page.driver.browser.logs.get(:browser)+ if logs.empty?+ lines << "(no logs)"+ else+ logs.each do |log|+ lines << log.message+ endend+ lines << "~~~~~ END JS LOGS ~~~~~"endendend