specs: save a screenshot of failing integration tests
This commit is contained in:
parent
197f691260
commit
394019b70c
3 changed files with 20 additions and 2 deletions
8
Gemfile
8
Gemfile
|
@ -124,19 +124,23 @@ gem "administrate"
|
|||
gem 'rack-mini-profiler'
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'launchy'
|
||||
gem 'factory_bot'
|
||||
gem 'database_cleaner'
|
||||
gem 'webmock'
|
||||
gem 'shoulda-matchers', require: false
|
||||
gem 'capybara-selenium'
|
||||
gem 'timecop'
|
||||
gem 'guard'
|
||||
gem 'guard-rspec', require: false
|
||||
gem 'guard-livereload', require: false
|
||||
gem 'vcr'
|
||||
gem 'rails-controller-testing'
|
||||
|
||||
# Integration testing
|
||||
gem 'capybara'
|
||||
gem 'capybara-selenium'
|
||||
# Save a dump of the page when an integration test fails
|
||||
gem 'capybara-screenshot'
|
||||
end
|
||||
|
||||
group :development do
|
||||
|
|
|
@ -118,6 +118,9 @@ GEM
|
|||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (>= 2.0, < 4.0)
|
||||
capybara-screenshot (1.0.21)
|
||||
capybara (>= 1.0, < 4)
|
||||
launchy
|
||||
capybara-selenium (0.0.6)
|
||||
capybara
|
||||
selenium-webdriver
|
||||
|
@ -798,6 +801,7 @@ DEPENDENCIES
|
|||
browser
|
||||
byebug
|
||||
capybara
|
||||
capybara-screenshot
|
||||
capybara-selenium
|
||||
carrierwave
|
||||
carrierwave-i18n
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in a new issue