diff --git a/test/integration/test_methods_system_test.rb b/test/integration/test_methods_system_test.rb index 15b2b646..869ee1ef 100644 --- a/test/integration/test_methods_system_test.rb +++ b/test/integration/test_methods_system_test.rb @@ -15,6 +15,8 @@ module Capybara module Screenshot module Diff class TestMethodsSystemTest < ActionDispatch::SystemTestCase + self.test_order = :random + include CapybaraScreenshotDiff::DSL include CapybaraScreenshotDiff::DSLStub diff --git a/test/support/setup_rails_app.rb b/test/support/setup_rails_app.rb index bfee43da..0e0fc20a 100644 --- a/test/support/setup_rails_app.rb +++ b/test/support/setup_rails_app.rb @@ -8,9 +8,7 @@ # NOTE: Simulate Rails Environment module Rails - def self.root - Pathname("../../tmp").expand_path(__dir__) - end + mattr_accessor(:root) { Pathname("../../tmp").expand_path(__dir__) } def self.application Rack::Builder.new { diff --git a/test/system_test_case.rb b/test/system_test_case.rb index bd26bafc..dddaffe9 100644 --- a/test/system_test_case.rb +++ b/test/system_test_case.rb @@ -6,6 +6,10 @@ require "support/setup_capybara_drivers" class SystemTestCase < ActiveSupport::TestCase + self.test_order = :random + # TODO: Handle race conditions in system tests by introducing git steps + parallelize(workers: 0) # Disable parallelization for system tests to prevent race conditions + setup do Capybara.current_driver = Capybara.javascript_driver Capybara.page.current_window.resize_to(*SCREEN_SIZE) diff --git a/test/test_helper.rb b/test/test_helper.rb index 6c136ab7..218ddf46 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -39,6 +39,14 @@ class ActiveSupport::TestCase # Set up fixtures and test helpers self.file_fixture_path = Pathname.new(File.expand_path("fixtures", __dir__)) + parallelize + + parallelize_setup do |i| + Rails.root = Pathname.new(File.expand_path("../tmp", __dir__)) / i.to_s + Capybara::Screenshot.root = Rails.root + FileUtils.mkdir_p(Capybara::Screenshot.root) + end + teardown do CapybaraScreenshotDiff::SnapManager.cleanup! unless persist_comparisons? end