specs: save a screenshot of failing integration tests

This commit is contained in:
Pierre de La Morinerie 2018-07-02 12:37:41 +02:00
parent 197f691260
commit 394019b70c
3 changed files with 20 additions and 2 deletions

View file

@ -22,6 +22,7 @@ ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require 'rspec/rails'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'database_cleaner'
require 'webmock/rspec'
require 'shoulda-matchers'
@ -50,6 +51,15 @@ ActiveSupport::Deprecation.silenced = true
Capybara.default_max_wait_time = 1
# Save a snapshot of the HTML page when an integration test fails
Capybara::Screenshot.autosave_on_failure = true
# Keep only the screenshots generated from the last failing test suite
Capybara::Screenshot.prune_strategy = :keep_last_run
# Tell Capybara::Screenshot how to take screenshots when using the headless_chrome driver
Capybara::Screenshot.register_driver :headless_chrome do |driver, path|
driver.browser.save_screenshot(path)
end
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }