Switch from chromedriver-helper to webdrivers (#2465) [ci skip]
This commit is contained in:
parent
859e0bc606
commit
8e6ca966ed
7 changed files with 45 additions and 19 deletions
|
|
@ -22,7 +22,7 @@ before_install:
|
|||
- nvm install
|
||||
install:
|
||||
- bundle install --path vendor/bundle
|
||||
- bundle exec chromedriver-update
|
||||
- bundle exec rails runner bin/chromedriver-update
|
||||
- yarn install
|
||||
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
||||
> ./cc-test-reporter
|
||||
|
|
|
|||
3
Gemfile
3
Gemfile
|
|
@ -133,14 +133,12 @@ end
|
|||
|
||||
group :test do
|
||||
gem "approvals", "~> 0.0" # A library to make it easier to do golden-master style testing in Ruby
|
||||
gem "chromedriver-helper", "~> 2.1" # Easy installation and use of chromedriver, the Chromium project's Selenium webdriver adapter
|
||||
gem "factory_bot_rails", "~> 4.11" # factory_bot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies
|
||||
gem "fake_stripe", "~> 0.2" # An implementation of the Stripe credit card processing service to run during your integration tests
|
||||
gem "launchy", "~> 2.4" # Launchy is helper class for launching cross-platform applications in a fire and forget manner.
|
||||
gem "pundit-matchers", "~> 1.6" # A set of RSpec matchers for testing Pundit authorisation policies
|
||||
gem "rspec-retry", "~> 0.6" # retry intermittently failing rspec examples
|
||||
gem "ruby-prof", "~> 0.17", require: false # ruby-prof is a fast code profiler for Ruby
|
||||
gem "selenium-webdriver", "~> 3.141" # WebDriver is a tool for writing automated tests of websites
|
||||
gem "shoulda-matchers", "4.0.1", require: false # Simple one-liner tests for common Rails functionality
|
||||
gem "simplecov", "~> 0.16", require: false # Code coverage with a powerful configuration library and automatic merging of coverage across test suites
|
||||
gem "stackprof", "~> 0.2", require: false, platforms: :ruby # stackprof is a fast sampling profiler for ruby code, with cpu, wallclock and object allocation samplers
|
||||
|
|
@ -148,6 +146,7 @@ group :test do
|
|||
gem "test-prof", "~> 0.7" # Ruby Tests Profiling Toolbox
|
||||
gem "timecop", "~> 0.9" # A gem providing "time travel" and "time freezing" capabilities, making it dead simple to test time-dependent code
|
||||
gem "vcr", "~> 4.0" # Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests
|
||||
gem "webdrivers", "~> 3.7" # Run Selenium tests more easily with install and updates for all supported webdrivers
|
||||
gem "webmock", "~> 3.5" # WebMock allows stubbing HTTP requests and setting expectations on HTTP requests
|
||||
gem "zonebie", "~> 0.6.1" # Runs your tests in a random timezone
|
||||
end
|
||||
|
|
|
|||
15
Gemfile.lock
15
Gemfile.lock
|
|
@ -111,8 +111,6 @@ GEM
|
|||
approvals (0.0.24)
|
||||
nokogiri (~> 1.6)
|
||||
thor (~> 0.18)
|
||||
archive-zip (0.11.0)
|
||||
io-like (~> 0.3.0)
|
||||
arel (9.0.0)
|
||||
ast (2.4.0)
|
||||
autoprefixer-rails (9.5.1)
|
||||
|
|
@ -191,9 +189,6 @@ GEM
|
|||
activesupport (>= 3)
|
||||
childprocess (0.9.0)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
chromedriver-helper (2.1.0)
|
||||
archive-zip (~> 0.10)
|
||||
nokogiri (~> 1.8)
|
||||
cld (0.8.0)
|
||||
ffi
|
||||
cloudinary (1.11.1)
|
||||
|
|
@ -562,7 +557,6 @@ GEM
|
|||
inline_svg (1.3.1)
|
||||
activesupport (>= 3.0)
|
||||
nokogiri (>= 1.6)
|
||||
io-like (0.3.0)
|
||||
ipaddress (0.8.3)
|
||||
jaro_winkler (1.5.2)
|
||||
jbuilder (2.8.0)
|
||||
|
|
@ -630,6 +624,7 @@ GEM
|
|||
nenv (0.3.0)
|
||||
net-http-persistent (3.0.0)
|
||||
connection_pool (~> 2.2)
|
||||
net_http_ssl_fix (0.0.10)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.10.2)
|
||||
|
|
@ -939,6 +934,11 @@ GEM
|
|||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
webdrivers (3.7.2)
|
||||
net_http_ssl_fix
|
||||
nokogiri (~> 1.6)
|
||||
rubyzip (~> 1.0)
|
||||
selenium-webdriver (~> 3.0)
|
||||
webmock (3.5.1)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
|
|
@ -987,7 +987,6 @@ DEPENDENCIES
|
|||
capybara (~> 3.13)
|
||||
carrierwave (~> 1.3)
|
||||
carrierwave-bombshelter (~> 0.2)
|
||||
chromedriver-helper (~> 2.1)
|
||||
cld (~> 0.8)
|
||||
cloudinary (~> 1.11)
|
||||
counter_culture (~> 2.1)
|
||||
|
|
@ -1066,7 +1065,6 @@ DEPENDENCIES
|
|||
sass-rails (~> 5.0)
|
||||
scout_apm (~> 2.4)
|
||||
sdoc (~> 1.0)
|
||||
selenium-webdriver (~> 3.141)
|
||||
serviceworker-rails (~> 0.5)
|
||||
shoulda-matchers (= 4.0.1)
|
||||
simplecov (~> 0.16)
|
||||
|
|
@ -1090,6 +1088,7 @@ DEPENDENCIES
|
|||
validate_url (~> 1.0)
|
||||
vcr (~> 4.0)
|
||||
web-console (~> 3.7)
|
||||
webdrivers (~> 3.7)
|
||||
webmock (~> 3.5)
|
||||
webpacker (~> 3.5)
|
||||
webpush (~> 0.3)
|
||||
|
|
|
|||
11
bin/chromedriver-update
Executable file
11
bin/chromedriver-update
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env ./bin/rails runner
|
||||
|
||||
# webdrivers 3.7.2 doesn't provide a standalone update script, so we made one
|
||||
|
||||
if Rails.env.test?
|
||||
# allow browser websites, so that "webdrivers" can access their binaries
|
||||
# see <https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock>
|
||||
WebMock.disable_net_connect!(allow: ["https://chromedriver.storage.googleapis.com"])
|
||||
|
||||
Webdrivers::Chromedriver.update
|
||||
end
|
||||
|
|
@ -4,7 +4,7 @@ We use the following testing tools:
|
|||
|
||||
- [**RSpec**](http://rspec.info/) for testing the backend
|
||||
- [**Capybara**](https://github.com/teamcapybara/capybara) with [**selenium-webdriver**](https://github.com/SeleniumHQ/selenium/tree/master/javascript/node/selenium-webdriver) for view testing
|
||||
- [**chromedriver-helper**](https://github.com/flavorjones/chromedriver-helper) for standard JS testing
|
||||
- [**webdrivers**](https://github.com/titusfortner/webdrivers) for standard JS testing
|
||||
- [**guard-rspec**](https://github.com/guard/guard-rspec) for automated testing
|
||||
- [**Jest**](https://facebook.github.io/jest) for testing in the front-end
|
||||
- [**preact-render-spy**](https://github.com/mzgoddard/preact-render-spy) for testing Preact components.
|
||||
|
|
|
|||
|
|
@ -36,7 +36,26 @@ Dir[Rails.root.join("spec", "jobs", "shared_examples", "**", "*.rb")].each { |f|
|
|||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
# Disable internet connection with Webmock
|
||||
WebMock.disable_net_connect!(allow_localhost: true)
|
||||
# allow browser websites, so that "webdrivers" can access their binaries
|
||||
# see <https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock>
|
||||
allowed_sites = [
|
||||
"https://chromedriver.storage.googleapis.com",
|
||||
"https://github.com/mozilla/geckodriver/releases",
|
||||
"https://selenium-release.storage.googleapis.com",
|
||||
"https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver",
|
||||
]
|
||||
WebMock.disable_net_connect!(allow_localhost: true, allow: allowed_sites)
|
||||
|
||||
# tell VCR to ignore browsers download sites
|
||||
# see <https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock>
|
||||
VCR.configure do |config|
|
||||
config.ignore_hosts(
|
||||
"chromedriver.storage.googleapis.com",
|
||||
"github.com/mozilla/geckodriver/releases",
|
||||
"selenium-release.storage.googleapis.com",
|
||||
"developer.microsoft.com/en-us/microsoft-edge/tools/webdriver",
|
||||
)
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.use_transactional_fixtures = true
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
require "capybara/rails"
|
||||
require "capybara/rspec"
|
||||
require "selenium/webdriver"
|
||||
|
||||
Capybara.default_max_wait_time = 5
|
||||
|
||||
Capybara.register_driver :headless_chrome do |app|
|
||||
Capybara::Selenium::Driver.new app,
|
||||
browser: :chrome,
|
||||
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
chromeOptions: { args: %w[headless disable-gpu no-sandbox window-size=1400,2000] },
|
||||
)
|
||||
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
chromeOptions: { args: %w[headless disable-gpu no-sandbox window-size=1400,2000] },
|
||||
)
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue