-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
By default Webpacker does not use config/webpack/test.js when running tests #2654
Comments
@alan-pie Thanks for opening this issue. It is worth some clarification, perhaps in the README or docs, as I would expect others would be surprised by this behavior as well. You are correct: when running Rails tests, by default, the Webpacker config specified by Ok, so why? First, let's make it clear that NODE_ENV has no explicit relationship to RAILS_ENV. Setting one of the ENV variables will have no effect on the other. This is useful for debugging; for example, you can compile your production webpack build locally by running Another key point the production and development configurations are designed for compiling your JS for a real browser. Though they have different optimization characteristics, they share the same browser-focused Babel config which will transform your nice ES6+ syntax into JavaScript your supported browsers will understand. So what's You can see the potential problem then if you explicitly set Edit I've adapted this answer into a blog post: https://rossta.net/blog/why-doesnt-webpacker-use-my-test-config-when-i-run-rails-tests.html |
Thanks for the clarification! Is this the right section of documentation to expand with this information? |
@alan-pie How about in https://github.com/rails/webpacker/blob/master/docs/testing.md? Would you like to close this issue out now that your question has been answered? |
Can you review the PR and I'll close it once the docs are updated? |
It is unintuitive to me that webpacker does not use config/webpack/test.js by default when doing rails test or rspec.
I have a small proof of concept minimal rails app with only the default rails gems + rspec, a single generated controller, and a "throw" statement in each environment.
rails test:system
shows that development.js is run by default.https://github.com/alan-pie/env-test
If this is intended, what is the right way to use "test.js"? Should I always specify NODE_ENV manually on the command line if I want the test configuration? Is this documented anywhere?
The text was updated successfully, but these errors were encountered: