Skip to content

Commit

Permalink
Run javascript specs on remote browser
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpierce committed Aug 25, 2023
1 parent 90f5e0b commit 25e873a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
command: |
/kaniko/executor \
--cache=true \
--build-arg "EXTRA_APK_PACKAGES=git bash chromium" \
--build-arg "EXTRA_APK_PACKAGES=git bash" \
--build-arg "APP_PATH=.<< parameters.hyrax_app >>" \
--build-arg "RUBY_VERSION=<< parameters.ruby_version >>" \
--context "git://github.com/samvera/hyrax#refs/heads/${CIRCLE_BRANCH}#${CIRCLE_SHA1}" \
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
HUB_URL: http://localhost:4444/wd/hub
HYRAX_VALKYRIE: << parameters.hyrax_valkyrie >>
IN_DOCKER: true
KARMA_BROWSER: ChromiumHeadlessCustom
KARMA_BROWSER: remote-chromium
VALKYRIE_SOLR_CORE: valkyrie-test
VALKYRIE_SOLR_PORT: 8985
steps:
Expand Down
3 changes: 2 additions & 1 deletion .dassie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ HYRAX_DERIVATIVES_PATH=/app/samvera/hyrax-webapp/derivatives/
HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/
IN_DOCKER=true
KARMA_BROWSER=ChromiumHeadlessCustom
KARMA_BROWSER=remote-chromium
KARMA_HOSTNAME=app
MEMCACHED_HOST=memcached
RACK_ENV=development
RAILS_ENV=development
Expand Down
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ chart/*

Gemfile.lock
.dassie/Gemfile.lock

node_modules/*
yarn.lock
2 changes: 2 additions & 0 deletions .koppie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/
HYRAX_VALKYRIE=true
IN_DOCKER=true
KARMA_BROWSER=remote-chromium
KARMA_HOSTNAME=app
METADATA_DATABASE_NAME=koppie_metadata_development
POSTGRES_DB=koppie
POSTGRES_HOST_AUTH_METHOD=trust
Expand Down
17 changes: 8 additions & 9 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = function(config) {
},

// web server port
hostname: process.env.KARMA_HOSTNAME || 'localhost', // This is the host the remote browser connects to
port: 9876,

// enable / disable colors in the output (reporters and logs)
Expand All @@ -80,16 +81,14 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: [process.env.KARMA_BROWSER],
browsers: [process.env.KARMA_BROWSER || 'ChromiumHeadless'],

customLaunchers: {
ChromiumHeadlessCustom: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox']
},
ChromeHeadlessCustom: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
'remote-chromium': {
base: 'SeleniumGrid',
gridUrl: process.env.HUB_URL || 'http://localhost:4444/wd/hub',
browserName: 'chrome',
arguments: [ '--headless=new']
}
},

Expand All @@ -99,6 +98,6 @@ module.exports = function(config) {

// Concurrency level
// how many browser instances should be started simultaneously
concurrency: 4
concurrency: 1
})
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"karma-chrome-launcher": "^3.1.1",
"karma-coffee-preprocessor": "^1.0.1",
"karma-jasmine": "^4.0.2",
"karma-spec-reporter": "^0.0.34"
"karma-selenium-grid-launcher": "^0.3.0",
"karma-spec-reporter": "^0.0.34",
"selenium-webdriver": "^4.10.0"
}
}
10 changes: 3 additions & 7 deletions spec/javascripts/jasmine_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# frozen_string_literal: true
require 'English'
require 'rake'

# Run the jasmine tests by running the karma javascript test framework
# The spec will fail if any jasmine tests fails.
RSpec.describe "Jasmine" do
before do
Rails.application.load_tasks
Rake::Task["assets:clobber"].invoke
Rake::Task["assets:precompile"].invoke
end

it "expects all jasmine tests to pass" do
# Ensure capybara is not using the remote browser
Capybara.using_driver(Capybara.javascript_driver) { Capybara.current_session.quit }

jasmine_out = `node_modules/karma/bin/karma start`

if $CHILD_STATUS.exitstatus == 0
Expand Down

0 comments on commit 25e873a

Please sign in to comment.