Skip to content

Commit

Permalink
Bundle JavaScript on-demand for JS feature specs (#6392)
Browse files Browse the repository at this point in the history
**Why**: So that developers don't need to be aware of and expend the effort to run "yarn build" every time before running a JavaScript-enabled feature spec, in order to avoid CSP errors related to the external Webpack dev server host.

changelog: Internal, Automated Testing, Improve developer ergonomics for running JavaScript-enabled integration specs
  • Loading branch information
aduth committed May 20, 2022
1 parent 0c067f9 commit 01d473d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -100,11 +100,11 @@ public/packs/manifest.json: yarn.lock $(shell find app/javascript -type f) ## Bu
yarn build

test: export RAILS_ENV := test
test: $(CONFIG) public/packs/manifest.json ## Runs RSpec and yarn tests
test: $(CONFIG) ## Runs RSpec and yarn tests
bundle exec rake parallel:spec && yarn test

fast_test: export RAILS_ENV := test
fast_test: public/packs/manifest.json ## Abbreviated test run, runs RSpec tests without accessibility specs
fast_test: ## Abbreviated test run, runs RSpec tests without accessibility specs
bundle exec rspec --exclude-pattern "**/features/accessibility/*_spec.rb"

tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt: ## Self-signed cert for local HTTPS development
Expand Down
7 changes: 7 additions & 0 deletions spec/rails_helper.rb
Expand Up @@ -66,6 +66,13 @@ class Analytics
end
end

if !ENV['CI']
config.before(:all, js: true) do
puts 'Bundling JavaScript...'
system 'make public/packs/manifest.json'
end
end

config.before(:each) do
I18n.locale = :en
end
Expand Down

0 comments on commit 01d473d

Please sign in to comment.