Webpacker throwing a tantrum when running controller tests

This happened after we rebuild the dev container, so I guess it’s equivalent to running rails test for the first time.

Error:
IslandersControllerTest#test_should_get_index:
ActionView::Template::Error: Webpacker can't find application in /workspaces/sixmilebridge/public/packs-test/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}

    app/views/layouts/application.html.erb:9
    test/controllers/islanders_controller_test.rb:9:in `block in <class:IslandersControllerTest>'

I have also seen this when using Rails with Docker.

I just encountered this. I ended up having to call rails webpacker:compile before testing. It’s confusing because in webpacker.yml the default is compile: true.

test:
  <<: *default
  compile: true

  # Compile test packs to a separate directory
  public_output_path: packs-test

@avdi Any chance you have a public repo for that so others can try to reproduce?

@rossta This isn’t Avdi’s repo, but the public repo I encountered this issue in is https://github.com/Terrastories/terrastories.

1 Like

Thanks @Betsy_Haibel, I’ll check it out!

@rossta Thanks!

In the spirit of the May of WTFs – right now, Terrastories is revamping its Docker setup & general project setup to make better tradeoffs re: “offlinability” & first-time developer experience. I’m part of those efforts. If, while you’re checking that project out, you encounter WTFs that seem to be Terrastories-related rather than Rails-related, I’d really appreciate your feedback – either talk to me or file an issue there directly.

Thanks @avdi and @mmccall10, since a couple of days (I believe since introducing system tests) our CircleCI tests were throwing this same error and it got fixed by adding a rails webpacker:compile step in our .circleci/config.yml :+1: For me this was definitely a WTF.

1 Like

Hi!, it also happened to me, I solved it running this command once:

rails webpacker:compile RAILS_ENV=test

after then, rails test command was execute correctly.

1 Like

Thank you! It solved my problem.