Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5 + Webpacker + react. Can't find application.js in system test

My app works in dev and in prod fine, but when I run a simple rails 5 system test I get:

ActionController::RoutingError: No route matches [GET] "/packs-test/application-ba6af2abeb41bbe4ad46.js"

I updated to the latest rails version and the latest webpacker. I've reinstalled webpacker with:

bundle exec rails webpacker:install
bundle exec rails webpacker:install:react

But I still get the error.

My webpacker.yml is out of the box so nothing special. I do see the application.js in the public/packs-test folder.

I'm using minitest for testing and really just visiting the sign in page causes the error.

visit sign_in_path
like image 333
jacklin Avatar asked Dec 09 '17 22:12

jacklin


2 Answers

Try running RAILS_ENV=test ./bin/rails webpacker:compile before running your tests.

like image 155
Jeff F. Avatar answered Nov 01 '22 00:11

Jeff F.


Ugh, this was caused by a setting in test.rb.

config.public_file_server.enabled = true

I had it changed to false (it should be true like shown above) because of a recommendation by simplecov to overcome some coverage misreporting due to spring.

like image 38
jacklin Avatar answered Nov 01 '22 00:11

jacklin