Skip to content

Commit

Permalink
Clarify Rails test use of config environments
Browse files Browse the repository at this point in the history
  • Loading branch information
asavageiv committed Sep 2, 2020
1 parent 5780a0a commit da4f4b6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,16 @@ Make sure you configure Rails to serve static files from the public directory in
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
```

## Webpacker Configuration Environments and Rails Tests

Webpacker ships with three configuration files in `config/webpack`:
`test.js`, `development.js`, and `production.js`. `NODE_ENV` determines which
webpack config it will use, i.e., config/webpack/{development,test,production}.js
and will impact behavior in your Babel config, i.e., `babel.config.js`.
`NODE_ENV` is independent of `RAILS_ENV` in Rails.

This means that by default `rails test` or `rspec` will use `development.js`
_not_ `test.js`, because `NODE_ENV` is `development` by [default](https://github.com/rails/webpacker/blob/bf278f9787704ed0f78038ad7d36c008abc2edfd/lib/install/bin/webpack#L4).

For more information see [Why doesn't Webpacker use my test config when I run Rails tests?](https://rossta.net/blog/why-doesnt-webpacker-use-my-test-config-when-i-run-rails-tests.html)

0 comments on commit da4f4b6

Please sign in to comment.