Rails 5 + Webpacker +做出反应.在系统测试中找不到application.js.

jac*_*lin 3 ruby-on-rails webpacker

我的应用程序在dev和prod工作正常,但当我运行简单的rails 5系统测试时,我得到:

ActionController::RoutingError: No route matches [GET] "/packs-test/application-ba6af2abeb41bbe4ad46.js"
Run Code Online (Sandbox Code Playgroud)

我更新了最新的rails版本和最新的webpacker.我重新安装了webpacker:

bundle exec rails webpacker:install
bundle exec rails webpacker:install:react
Run Code Online (Sandbox Code Playgroud)

但我仍然得到错误.

我的webpacker.yml是开箱即用的,所以没什么特别的.我确实在public/packs-test文件夹中看到了application.js.

我正在使用minitest进行测试,而且只是访问登录页面会导致错误.

visit sign_in_path
Run Code Online (Sandbox Code Playgroud)

Jef*_* F. 6

RAILS_ENV=test ./bin/rails webpacker:compile在运行测试之前尝试运行.


jac*_*lin 6

呃,这是由 test.rb 中的设置引起的。

config.public_file_server.enabled = true
Run Code Online (Sandbox Code Playgroud)

由于 simplecov 建议克服由于春季引起的一些覆盖误报,我将其更改为 false(如上所示应该为 true)。