console_errors.rb 720 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.configure do |config|
  3. config.after(:each, type: :system) do
  4. next if page.driver.browser.browser != :chrome
  5. logs = page.driver.browser.logs.get(:browser)
  6. errors = logs.select { |m| m.level == 'SEVERE' && m.to_s =~ %r{EvalError|InternalError|RangeError|ReferenceError|SyntaxError|TypeError|URIError|E60(0|1)} }
  7. if errors.present?
  8. Rails.logger.error "JS ERRORS: #{errors.to_json}"
  9. errors.each do |error|
  10. puts "#{error.message}\n\n"
  11. end
  12. Rails.root.join('log/browser.log').write(logs.map { |l| "#{l.level}|#{l.message}" }.join("\n"))
  13. end
  14. expect(errors.length).to eq(0)
  15. end
  16. end