I'm using system tests in Rails 5.1, and I'd like to turn off the automated screenshots for failure cases. Usually the failure message is plenty for me to figure out what's going on — and notably, the webdriver browser window always takes focus in order to take a screenshot, which is annoying when I'm working on the code (or trying to do anything else).
Is there a built in way in Capybara configuration to turn off screenshots? I looked through the docs and couldn't find anything stated explicitly, but since this is a new-ish addition to mainstream Rails, I figure that doesn't necessarily mean it doesn't exist.
In Rails 5.1 ActionDispatch::SystemTestCase (from which ApplicationSystemTestCase derives) has a default after_teardown
method of
def after_teardown
take_failed_screenshot
Capybara.reset_sessions!
super
end
To stop this from taking a screenshot, the easiest method is to override take_failed_screenshot
in your ApplicationSystemTestCase class
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by ...
# Add this method
def take_failed_screenshot
false
end
end