We don’t want to compile assets during test runs, since that is slow, but we also don’t want the asset pipeline to fail because assets are missing.
This will not work if you plan on doing javascript integration tests, but everything else should work fine.
Rails 5.1 added a flag for this which prints deprecations and will be removed in rails 5.2 so that is not a elegant solution either.
config.assets.unknown_asset_fallback = true
So we are now using this fix to fake assets being available!:
# config/environments/test.rb # make our tests fast by avoiding asset compilation # but do not raise when assets are not compiled either Rails.application.config.assets.compile = false Sprockets::Rails::Helper.prepend(Module.new do def resolve_asset_path(path, *) super || path end end)