Last active
February 24, 2016 08:09
-
-
Save piotrze/c9ef67eac23a797d9ee1 to your computer and use it in GitHub Desktop.
Save screenshot on failed integration tests with capybara.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test/test_helper.rb | |
class ActionDispatch::IntegrationTest | |
def after_teardown | |
if !passed? | |
timestamp = "#{Time.zone.now.strftime('%Y-%m-%d-%H:%M:%S')}" | |
screenshot_name = "screenshot-#{timestamp}.png" | |
# Handle CircleCi too | |
screenshot_path = "#{ENV.fetch('CIRCLE_ARTIFACTS', Rails.root.join('tmp/capybara'))}/#{screenshot_name}" | |
page.save_screenshot(screenshot_path) | |
end | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment