Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Configure teaspoon on chrome headless; not working
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgriffis committed Jun 27, 2018
1 parent d6fa3ff commit 81ccd1c
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 4 deletions.
27 changes: 27 additions & 0 deletions Dockerfile.e2e_test
@@ -0,0 +1,27 @@
FROM nyulibraries/selenium_chrome_headless_ruby:2.3

ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH

# ENV BUILD_PACKAGES git build-essential zlib1g-dev
ENV RUN_PACKAGES git
RUN apt-get -y --no-install-recommends install $RUN_PACKAGES \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Add github to known_hosts
RUN mkdir -p ~/.ssh
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts

# Bundle install
COPY Gemfile Gemfile.lock ./
RUN bundle config --global github.https true
# RUN apt-get update && apt-get -y --no-install-recommends install $BUILD_PACKAGES \
RUN gem install bundler && bundle install --jobs 20 --retry 5
# && apt-get --purge -y autoremove $BUILD_PACKAGES \
# && apt-get clean && rm -rf /var/lib/apt/lists/*

# COPY spec ./spec
# COPY features ./features
COPY . .

CMD bundle exec rake teaspoon features
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -51,6 +51,9 @@ group :development, :test do
gem 'teaspoon-jasmine', '~> 2.3.4'
gem 'factory_bot_rails', '~> 4.8.2'
gem 'rspec-rails', '~> 3.7.0'

gem 'selenium-webdriver', '~> 3.6.x'
gem 'chromedriver-helper', '~> 1.1.x'
end

# Testing gems
Expand Down
16 changes: 14 additions & 2 deletions Gemfile.lock
Expand Up @@ -121,6 +121,8 @@ GEM
akami (1.3.1)
gyoku (>= 0.4.0)
nokogiri
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (6.0.4)
autoprefixer-rails (8.0.0)
execjs
Expand All @@ -145,6 +147,11 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.2.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
chunky_png (1.3.8)
citero (1.0.0.beta)
ox (~> 2.8.0)
Expand Down Expand Up @@ -268,6 +275,7 @@ GEM
institutions (0.1.3)
ipaddr_range_set (~> 0.10.0)
require_all (~> 1.3.1)
io-like (0.3.0)
ipaddr_range_set (0.10.0)
iso-639 (0.2.8)
jquery-rails (4.3.1)
Expand Down Expand Up @@ -391,6 +399,7 @@ GEM
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
rubyzip (1.2.1)
rvm-capistrano (1.5.6)
capistrano (~> 2.15.4)
safe_yaml (1.0.4)
Expand All @@ -410,6 +419,9 @@ GEM
nori (~> 2.4)
wasabi (~> 3.4)
scrub_rb (1.0.1)
selenium-webdriver (3.13.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
Expand All @@ -427,7 +439,6 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.13)
teaspoon (1.1.5)
railties (>= 3.2.5, < 6)
teaspoon-jasmine (2.3.4)
Expand Down Expand Up @@ -467,6 +478,7 @@ PLATFORMS
DEPENDENCIES
activerecord-import (~> 0.18.0)
acts-as-taggable-on (~> 3.4.0)
chromedriver-helper (~> 1.1.x)
citero_engine (= 3.0.0.beta)
coffee-rails (~> 4.2.1)
compass-rails (~> 2.0.0)
Expand Down Expand Up @@ -499,8 +511,8 @@ DEPENDENCIES
rspec-mocks
rspec-rails (~> 3.7.0)
sass-rails (~> 5.0.6)
selenium-webdriver (~> 3.6.x)
sorted (~> 1.0.0)
sqlite3
teaspoon-jasmine (~> 2.3.4)
therubyracer (~> 0.12.3)
uglifier (~> 3.2.0)
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Expand Up @@ -26,6 +26,21 @@ services:
depends_on:
- setup_test_dbs

test_js:
build:
context: .
dockerfile: Dockerfile.e2e_test
environment:
RAILS_ENV: test
PRIMO_BASE_URL: http://primo.library.edu
env_file:
- test.env
command: ["rake", "teaspoon", "features"]
shm_size: 1g
tty: true
depends_on:
- setup_test_dbs

setup_test_dbs:
build: .
environment:
Expand Down
33 changes: 31 additions & 2 deletions spec/teaspoon_env.rb
@@ -1,3 +1,5 @@
require 'selenium-webdriver'

Teaspoon.configure do |config|
# Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to
# `http://localhost:3000/jasmine` to run your tests.
Expand Down Expand Up @@ -97,14 +99,41 @@
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
# Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
#config.driver = :phantomjs
config.driver = :selenium

# Specify additional options for the driver.
#
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
# Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
#config.driver_options = nil
# config.driver_options = {
# client_driver: :chrome_headless,
# custom_driver: {
# chrome_headless: {
# base: :chrome,
# flags: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage']
# }
# }
# }

# Specify additional options for the driver.
#
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--disable-gpu'
# Required for chrome to work in container based Travis environment
# (see https://docs.travis-ci.com/user/chrome)
browser_options.args << '--no-sandbox'
browser_options.args << '--disable-extensions'
browser_options.args << '--disable-dev-shm-usage'
config.driver_options = {
client_driver: :chrome,
client_driver_opts: {
options: browser_options
}
}

# Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be
# considered a failure. This is to avoid issues that can arise where tests stall.
Expand Down

0 comments on commit 81ccd1c

Please sign in to comment.