webpacker: Can't find packs using Capybara/RSpec
Ruby 2.3.1 Rails 5.1.3 Webpacker 3.0.2
I’m using Webkit as my JS driver. I can find the packs while in prod and dev but cannot get my React components to render while running tests.
I have this in my rails_helper.rb and it generates the correct files.
config.before(:suite) do # compile front-end Webpacker.compile end
Manifest file:
{ "application.js": "/assets/packs-test/application-1b884d2f94460a1a42f1.js" }
Output from save_and_open_page
<script src="/assets/packs-test/application-1b884d2f94460a1a42f1.js"></script>
My manifest file looks good as well and it pointing in the right files. Do I have to serve these files up with a different process to get them to render?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 29 (18 by maintainers)
Commits related to this issue
- Add capybara configuration to testing.rb (#1340) https://github.com/rails/webpacker/issues/998 — committed to rails/webpacker by smarquez1 6 years ago
- upgrade webpack This update follows https://github.com/rails/webpacker/issues/998 — committed to an-ju/projectscope by an-ju 6 years ago
- fix rspec ci ci is failing since it for some reason refused to generate webpack output this seems to be caused by some differences between home bundler runs rspec in ci vs in local ref: https://git... — committed to ignatiusreza/zscore by ignatiusreza 5 years ago
- Add capybara configuration to testing.rb (#1340) https://github.com/rails/webpacker/issues/998 — committed to KingTiger001/Rails-web-pack-project by KingTiger001 6 years ago
- Add capybara configuration to testing.rb (#1340) https://github.com/rails/webpacker/issues/998 — committed to smartech7/ruby-webpacker by smarquez1 6 years ago
I solved this issue in Rails 5.2 rc1 by setting this variable in
test.rb
:Thanks, everyone for keeping this thread updated. We have added an info task to show version info, thanks to @ytbryan :
Will make a new release today.
this instantly fixed my issue with React components included via
react-rails
gem not displaying in RSpec tests (js: true) using Capybara/Selenium.I had the same error mentioned in https://github.com/rails/webpacker/issues/998#issuecomment-375597197 but it was because I needed to add the following to Codeship setup commands:
I have the same problem locally after deleting the
public/packs-test
folder.I use
Error in test
I added
config.public_file_server.enabled = true
inconfig/environments/test.rb
but it did not change a thing. How could I proceed here?edit Also happens with Rails Version 5.2.0.rc1 from branch
5-2-stable
.edit 2 Perhaps this is old news, but if I downgrade
webpacker
to3.2.2
it works again. It did not work with version3.3.1
or3.3.0
.edit 3 OR RTFM => https://github.com/rails/webpacker/blob/master/CHANGELOG.md#breaking-changes
bundle exec rails webpacker:binstubs
Now everything works for me again. Sorry again if this was old news for you.