BigW Consortium Gitlab

capybara.rb 800 Bytes
Newer Older
1 2 3
require 'spinach/capybara'
require 'capybara/poltergeist'

4
# Give CI some extra time
5
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 90 : 15
6

7 8
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
9 10 11 12 13 14 15 16 17
  Capybara::Poltergeist::Driver.new(
    app,
    js_errors: true,
    timeout: timeout,
    window_size: [1366, 768],
    phantomjs_options: [
      '--load-images=no'
    ]
  )
18 19
end

20
Capybara.default_max_wait_time = timeout
21 22
Capybara.ignore_hidden_elements = false

23 24
unless ENV['CI'] || ENV['CI_SERVER']
  require 'capybara-screenshot/spinach'
25

26 27 28
  # Keep only the screenshots generated from the last failing test suite
  Capybara::Screenshot.prune_strategy = :keep_last_run
end
29 30

Spinach.hooks.before_run do
31
  TestEnv.warm_asset_cache unless ENV['CI'] || ENV['CI_SERVER']
32
end