Compile Webpacker assets only once in test environment

This commit is contained in:
Matt-Yorkley
2021-06-14 20:22:17 +01:00
parent 658f0eccbb
commit a23171ea51
2 changed files with 13 additions and 9 deletions

View File

@@ -71,15 +71,7 @@ development:
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
production: &production
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
@@ -90,3 +82,9 @@ production:
# Cache manifest.json for performance
cache_manifest: true
test:
<<: *production
# Compile test packs to a separate directory
public_output_path: packs-test

View File

@@ -55,6 +55,12 @@ RSpec.configure do |config|
Capybara.reset_sessions!
end
# Precompile Webpacker assets (once) when starting the suite. The default setup can result
# in the assets getting compiled many times throughout the build, slowing it down.
config.before :suite do
Webpacker.compile
end
# Fix encoding issue in Rails 5.0; allows passing empty arrays or hashes as params.
config.before(:each, type: :controller) { @request.env["CONTENT_TYPE"] = 'application/json' }