mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-21 18:05:23 -05:00
Add details to JS browser error spec failure helpers (#37441)
This commit is contained in:
parent
a9cfddf28e
commit
0fb4e26cfe
|
|
@ -4,6 +4,10 @@ module BrowserErrorsHelpers
|
|||
def ignore_js_error(error)
|
||||
@ignored_js_errors_for_spec << error
|
||||
end
|
||||
|
||||
def error_message(error)
|
||||
error.keys.map { |key| "#{key.to_s.titleize}: #{error[key]}" }.join("\n")
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
|
@ -15,7 +19,7 @@ RSpec.configure do |config|
|
|||
example.metadata[:js_console_messages] ||= []
|
||||
Capybara.current_session.driver.with_playwright_page do |page|
|
||||
page.on('console', lambda { |msg|
|
||||
example.metadata[:js_console_messages] << { type: msg.type, text: msg.text, location: msg.location }
|
||||
example.metadata[:js_console_messages] << { type: msg.type, text: msg.text, location: msg.location, page: msg.page.url }
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
@ -34,7 +38,7 @@ RSpec.configure do |config|
|
|||
if errors.present?
|
||||
aggregate_failures 'browser errrors' do
|
||||
errors.each do |error|
|
||||
expect(error[:type]).to_not eq('error'), error[:text]
|
||||
expect(error[:type]).to_not eq('error'), error_message(error)
|
||||
next unless error[:type] == 'warning'
|
||||
|
||||
warn 'WARN: browser warning'
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user