If I run tests with bin/rails test it triggers yarn to run twice, once for esbuild and once for css. If I run all the same tests with bin/rails test test/**/**.rb or bin/rails test test/ the tests run instantly.
Why is this happening when I'm not running System Tests)?
Versions: Rails 7.1.1, Ruby 3.2.2, Minitest 5.20.0
App created with rails new my_app --javascript esbuild --css bootstrap
Additional question - How do I figure this out for myself next time?
My test helper doesn't seem to be calling rails test:prepare or anything else that triggers yarn:
# test/test_helper.rb
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
module ActiveSupport
class TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
end
I've tried to go through each required file in test_helper.rb and can't find anywhere else that yarn/assets/precompilation is being told to happen:
../config/environment❌config/application❌config/boot❌rails/all❓ (didn't even know where to begin)
rails/test_help❓ (read through source but only looked in to one of the things it requires)active_support/testing/autorun❌ (source)
I also tried bundle open minitest on the off chance something is configured there but I poked around a bit and couldn't see anything relevant.
Where is the yarn/asset-compilation "magic" configured for tests?
When you call
rails testwithout any arguments it callstest:preparefor you Sourceand Source
As Noted in the Upgrade Guide
You can see that this indeed builds
yarnCssbundling and Jsbundling