Eager load the test environment like in Rails 7

Quoting from pull request 43508 in the Rails repository [1]:

> When you are running test locally, most of the time you run only a
> subset, so it's better to load as little code as possible to have a
> faster time to first test result.
>
> But when you are on CI, it's usually much preferable to eager load the
> whole application because you will likely need all the code anyway,
> and even if the test suite is split across runners, it's preferable to
> load all the code to ensure any codefile that may have side effects is
> loaded.
>
> This also ensure that if some autoloaded constants are not properly
> tested on CI, at least they'll be loaded and obvious errors (e.g.
> SyntaxError) will be caught on CI rather than during deploy.

[1] https://github.com/rails/rails/commit/db0ee287eed
This commit is contained in:
Javi Martín
2023-07-25 05:27:57 +02:00
parent 6552e3197d
commit 59f84deca1

View File

@@ -20,7 +20,7 @@ Rails.application.configure do
# Do not eager load code on boot. This avoids loading your whole application # Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that # just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true. # preloads Rails for running tests, you may have to set it to true.
config.eager_load = false config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true