I have one js pack file that is causing a problem in the test environment: packs/smooth-scroller
In app/javascript/packs/application.js
require("packs/smooth-scroller")
Tried changing to application.js.erb and using:
require("packs/smooth-scroller") unless Rails.environment.test?
And updated webpack.yml to include
extensions:
- .erb
But this raised errors:
Failure/Error:
respond_to do |format|
format.js { render '/pages/waitlist_submissions' }
end
ActionController::UnknownFormat:
ActionController::UnknownFormat
And, injecting unless Rails.environment.test?
is pretty stinky.
So, what is a good way to suppress a js require
, or replace the file with a blank file, in the test environment?
Rails 6
question from:
https://stackoverflow.com/questions/65876065/how-to-suppress-a-js-pack-in-test-environment-in-rails 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…