Skip to content

Commit

Permalink
Merge pull request #2783 from alphagov/revert-2771-revert-2763-migrat…
Browse files Browse the repository at this point in the history
…e-to-jasmine-browser

Re-apply use of jasmine-browser-runner (re-reverts #2771)
  • Loading branch information
chao-xian authored May 24, 2022
2 parents f4c859c + 321cf70 commit 39662ec
Show file tree
Hide file tree
Showing 17 changed files with 550 additions and 181 deletions.
4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ updates:
- dependency-name: rubocop-govuk
dependency-type: direct
# Framework gems
- dependency-name: jasmine-rails
- dependency-name: jasmine-browser-runner
dependency-type: direct
- dependency-name: jasmine-core
dependency-type: direct
- dependency-name: minitest
dependency-type: direct
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ end

group :development, :test do
gem "govuk_test"
gem "jasmine"
gem "jasmine_selenium_runner"
gem "pry"
gem "rubocop-govuk"
end
Expand Down
11 changes: 0 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,7 @@ GEM
progress (~> 3.0, >= 3.0.1)
image_size (2.1.0)
in_threads (1.5.4)
jasmine (3.6.0)
jasmine-core (~> 3.6.0)
phantomjs
rack (>= 1.2.1)
rake
jasmine-core (3.6.0)
jasmine_selenium_runner (3.0.0)
jasmine (~> 3.0)
selenium-webdriver (~> 3.8)
json-schema (2.8.1)
addressable (>= 2.4)
kgio (2.11.4)
Expand Down Expand Up @@ -194,7 +186,6 @@ GEM
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
phantomjs (2.1.1.0)
plek (4.0.0)
progress (3.5.2)
prometheus_exporter (2.0.3)
Expand Down Expand Up @@ -352,9 +343,7 @@ DEPENDENCIES
govuk_publishing_components
govuk_test
image_optim
jasmine
jasmine-core
jasmine_selenium_runner
listen
minitest
minitest-capybara
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bundle exec rake
To run JavaScript tests (only):

```
env RAILS_ENV=test bundle exec rake jasmine:ci
env RAILS_ENV=test bundle exec rake jasmine
```

### Further documentation
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ require File.expand_path("config/application", __dir__)
Rails.application.load_tasks

Rake::Task[:default].clear if Rake::Task.task_defined?(:default)
task default: %i[lint jasmine:ci test]
task default: %i[lint jasmine test]
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
//= link application.css
//= link guides-print.css
//= link print.css
//= link modules/base-target.js
4 changes: 4 additions & 0 deletions lib/tasks/jasmine.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
desc "Run Jasmine tests"
task jasmine: :environment do
sh "yarn run jasmine:ci"
end
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"scripts": {
"lint": "yarn run lint:js && yarn run lint:scss",
"lint:js": "standardx 'app/assets/javascripts/**/*.js' 'spec/javascripts/**/*.js'",
"lint:scss": "stylelint app/assets/stylesheets/"
"lint:scss": "stylelint app/assets/stylesheets/",
"jasmine:prepare": "RAILS_ENV=test bundle exec rails assets:clobber assets:precompile",
"jasmine:ci": "yarn run jasmine:prepare && yarn run jasmine-browser-runner runSpecs",
"jasmine:browser": "yarn run jasmine:prepare && yarn run jasmine-browser-runner"
},
"standardx": {
"env": {
Expand All @@ -32,6 +35,8 @@
"extends": "stylelint-config-gds/scss"
},
"devDependencies": {
"jasmine-browser-runner": "^1.0.0",
"jasmine-core": "^4.1.0",
"standardx": "^7.0.0",
"stylelint": "^14.8.3",
"stylelint-config-gds": "^0.2.0"
Expand Down
2 changes: 0 additions & 2 deletions spec/javascripts/global-bar-init.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// = require global-bar-init

/* global globalBarInit, parseCookie, expectGlobalBarToShow, expectGlobalBarToBeHidden */

describe('Global bar initialize', function () {
Expand Down
2 changes: 0 additions & 2 deletions spec/javascripts/modules/base-target.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// = require modules/base-target

describe('A base target module', function () {
'use strict'

Expand Down
2 changes: 2 additions & 0 deletions spec/javascripts/modules/global-bar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ describe('Global bar module', function () {
var element

beforeEach(function () {
window.GOVUK.setConsentCookie({ settings: true })
document.cookie = 'global_bar_seen=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
})

afterEach(function () {
window.GOVUK.setConsentCookie({ settings: null })
$('#global-bar').remove()
})

Expand Down
142 changes: 0 additions & 142 deletions spec/javascripts/support/jasmine.yml

This file was deleted.

7 changes: 0 additions & 7 deletions spec/javascripts/support/jasmine_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/javascripts/support/jasmine_selenium_runner.yml

This file was deleted.

5 changes: 2 additions & 3 deletions spec/javascripts/surveys.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// = require surveys
//= require govuk_publishing_components/lib/trigger-event.js

describe('Surveys', function () {
var surveys = GOVUK.userSurveys
var $block
Expand Down Expand Up @@ -29,6 +26,7 @@ describe('Surveys', function () {
}

beforeEach(function () {
window.GOVUK.setConsentCookie({ settings: true })
$block = $('<div class="emergency-banner" style="display: none"></div>' +
'<div id="global-cookie-message" style="display: none"></div>' +
'<div id="taxonomy-survey" style="display: none"></div>' +
Expand Down Expand Up @@ -58,6 +56,7 @@ describe('Surveys', function () {
})
$block.remove()
$('#global-bar').remove()
window.GOVUK.setConsentCookie({ settings: null })
})

describe('init', function () {
Expand Down
21 changes: 21 additions & 0 deletions spec/support/jasmine-browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"srcDir": "public/assets/static",
"srcFiles": [
"application-*.js",
"modules/base-target-*.js"
],
"cssFiles": [
"application-*.css"
],
"specDir": "spec/javascripts",
"specFiles": [
"**/*[sS]pec.js"
],
"helpers": [
"vendor/jquery-1.12.4.js",
"vendor/jasmine-jquery-2.0.5.js",
"vendor/mock-ajax.js",
"helpers/*.js"
],
"browser": "headlessChrome"
}
Loading

0 comments on commit 39662ec

Please sign in to comment.