When building a new feature, system tests can be incredibly handy. They let you walk through the UI like a user, catch errors as controllers are scaffolded, and jump into lower-level tests when logic starts branching.
But David said (mostly) not to… System tests can be slow and brittle, and they don’t always provide the best return on investment.
Here’s a practical approach you can use:
To mark a system test as a smoke test so it runs as part of the test suite, add a tag:
RSpec.describe "QuickAdds", :smoke_test, type: :system do
end
In your rails_helper.rb
config, you can conditionally exclude all non-smoke system tests:
RSpec.configure do |config|
if ENV['SKIP_NON_SMOKE_TESTS']
config.filter_run_excluding type: ->(type, example) do
types_to_exclude = [:system, :feature]
types_to_exclude.include?(type) && !example[:smoke_test]
end
end
end
By default, all tests run, so you’re safe even if the environment variable is misconfigured. When SKIP_NON_SMOKE_TESTS
is set, system or feature tests without the :smoke_test
tag will be skipped.
This setup makes it easy to see test coverage without system tests artificially inflating the numbers, while still letting you use system tests where they add value and keeping the suite performant.
With this approach, you get the best of both worlds: system tests when you need them, fast feedback when you don’t.