title: Is there a way to cleanup database tests in Rails 6.0.3.1 System Tests. I thought Rails does the cleanup?
body: <p>Using</p>
  
  <ul>
  <li>Ruby <code>"2.7.1"</code></li>
  <li>Rails <code>"6.0.3.1"</code></li>
  <li><p>Mac OS Catalina 10.15.5</p></li>
  <li><p>Using the default Rails Minitest and FactoryBot for test data.</p></li>
  </ul>
  
  <p><strong>Issue:</strong> I have test data being shared between system test files and hence failing tests. When I run the system test files individually the tests pass but this is inconvenient.</p>
  
  <p>I use the the system test config out of the box as in the <code>application_system_test_case.rb</code></p>
  
  <p><strong>This is my system test scenario.</strong>
  I have 3 <code>Customers</code> in <code>customers_system_test.rb</code> file and 1 <code>Customer</code> (so far) in <code>job_description_system_test.rb</code> Customer 1 appears in the <code>customers_system_test.rb</code> failing test screenshots that Rails conveniently provide.</p>
  
  <p>Note: The 3 failing tests all concern record counts such as <code>assert_equal Customer.count, 3</code> </p>
  
  <p><strong>The 3 failing tests</strong></p>
  
  <pre><code>test "visit create customer and navigate back" do
    ...
    assert_equal Customer.count, 3
  end
  </code></pre>
  
  <pre><code>test "cancel destroying a customer" do
    assert_equal Customer.count, 3
    ...  
  end
  </code></pre>
  
  <pre><code>test "destroy a customer" do
    assert_equal Customer.count, 3
    ...
  end
  </code></pre>
  
  <p>Interestingly I had the same issue with test data not being cleaned up when running <code>rails test</code> for controller, integration tests etc: The way I get around that is adding the following snippet to the <code>test_helper.rb</code> :</p>
  
  <p><code>(ActiveRecord::Base.connection.tables - %w{schema_migrations}).each do |table_name|</code>
    <code>ActiveRecord::Base.connection.execute "TRUNCATE TABLE #{table_name} CASCADE;"</code>
  <code>end</code> Doesn't work for system tests</p>
  
  <p>I feel like I am missing the obvious?</p>
  
  <p><code>test_helper.rb</code></p>
  
  <pre><code>require "simplecov"
  SimpleCov.start "rails"
  
  ENV["RAILS_ENV"] ||= "test"
  require_relative "../config/environment"
  require "rails/test_help"
  
  class ActiveSupport::TestCase
    include FactoryBot::Syntax::Methods
    include Warden::Test::Helpers
  
    # Run tests in parallel with specified workers
    # parallelize(workers: :number_of_processors)
    parallelize(workers: 1)
  
    # 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...
    include Devise::Test::IntegrationHelpers
  end
  
  (ActiveRecord::Base.connection.tables - %w{schema_migrations}).each do |table_name| 
    ActiveRecord::Base.connection.execute "TRUNCATE TABLE #{table_name} CASCADE;"
  end
  </code></pre>