Jonathan Bennett

Only Running Smoke Tests: A Practical Guide

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:

  1. Keep most of your system tests as ephemeral tools outside the main test suite, or just drop them.
  2. Tag system tests that you want to run regularly as part of the test suite.
  3. Use an environment variable to control whether those tagged tests are executed.

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.