Merge pull request #2184 from betagouv/capybara-screenshots
specs: automatically save a screenshot of failing integration tests
This commit is contained in:
commit
b6ea2f1b36
3 changed files with 20 additions and 2 deletions
8
Gemfile
8
Gemfile
|
@ -124,19 +124,23 @@ gem "administrate"
|
||||||
gem 'rack-mini-profiler'
|
gem 'rack-mini-profiler'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'capybara'
|
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
gem 'factory_bot'
|
gem 'factory_bot'
|
||||||
gem 'database_cleaner'
|
gem 'database_cleaner'
|
||||||
gem 'webmock'
|
gem 'webmock'
|
||||||
gem 'shoulda-matchers', require: false
|
gem 'shoulda-matchers', require: false
|
||||||
gem 'capybara-selenium'
|
|
||||||
gem 'timecop'
|
gem 'timecop'
|
||||||
gem 'guard'
|
gem 'guard'
|
||||||
gem 'guard-rspec', require: false
|
gem 'guard-rspec', require: false
|
||||||
gem 'guard-livereload', require: false
|
gem 'guard-livereload', require: false
|
||||||
gem 'vcr'
|
gem 'vcr'
|
||||||
gem 'rails-controller-testing'
|
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
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
@ -118,6 +118,9 @@ GEM
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (>= 2.0, < 4.0)
|
xpath (>= 2.0, < 4.0)
|
||||||
|
capybara-screenshot (1.0.21)
|
||||||
|
capybara (>= 1.0, < 4)
|
||||||
|
launchy
|
||||||
capybara-selenium (0.0.6)
|
capybara-selenium (0.0.6)
|
||||||
capybara
|
capybara
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
|
@ -798,6 +801,7 @@ DEPENDENCIES
|
||||||
browser
|
browser
|
||||||
byebug
|
byebug
|
||||||
capybara
|
capybara
|
||||||
|
capybara-screenshot
|
||||||
capybara-selenium
|
capybara-selenium
|
||||||
carrierwave
|
carrierwave
|
||||||
carrierwave-i18n
|
carrierwave-i18n
|
||||||
|
|
|
@ -22,6 +22,7 @@ ENV['RAILS_ENV'] ||= 'test'
|
||||||
require File.expand_path('../config/environment', __dir__)
|
require File.expand_path('../config/environment', __dir__)
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
require 'capybara/rspec'
|
require 'capybara/rspec'
|
||||||
|
require 'capybara-screenshot/rspec'
|
||||||
require 'database_cleaner'
|
require 'database_cleaner'
|
||||||
require 'webmock/rspec'
|
require 'webmock/rspec'
|
||||||
require 'shoulda-matchers'
|
require 'shoulda-matchers'
|
||||||
|
@ -50,6 +51,15 @@ ActiveSupport::Deprecation.silenced = true
|
||||||
|
|
||||||
Capybara.default_max_wait_time = 1
|
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,
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||||
# in spec/support/ and its subdirectories.
|
# in spec/support/ and its subdirectories.
|
||||||
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
||||||
|
|
Loading…
Reference in a new issue