Run webpack before tests in Rails 5.1 and RSpec
When running tests via RSpec in Rails 5.1 with Webpack support (via the built-in webpacker gem) you need to have Webpack compile your front-end assets before running your tests. To achieve that in RSpec add the following to your rails_helper.rb
:
config.before(:suite) do
# compile front-end and load manifest
`bin/webpack`
Webpacker::Manifest.load
end
Tweet