|
88 | 88 | FactoryBot.reload |
89 | 89 | end |
90 | 90 |
|
91 | | - config.after(:each, js: true) do |example| |
92 | | - if example.exception |
93 | | - screenshot_path = Rails.root.join("tmp/screenshots", "#{method_name}-#{Time.zone.now.strftime("%Y_%m_%d-%H_%M_%S")}.png") |
94 | | - Capybara.page.save_screenshot(screenshot_path) |
95 | | - end |
96 | | - end |
97 | | - |
98 | 91 | config.around(:each, caching: true) do |example| |
99 | 92 | Rails.configuration.action_controller.perform_caching = true |
100 | 93 | example.run |
|
105 | 98 | driven_by :rack_test |
106 | 99 | end |
107 | 100 |
|
| 101 | + Capybara.register_driver :headless_chrome do |app| |
| 102 | + options = Selenium::WebDriver::Chrome::Options.new |
| 103 | + options.add_argument('--headless=new') |
| 104 | + options.add_argument('--disable-gpu') |
| 105 | + options.add_argument('--no-sandbox') |
| 106 | + options.add_argument('--disable-dev-shm-usage') |
| 107 | + options.add_argument('--window-size=1400,1400') |
| 108 | + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) |
| 109 | + end |
| 110 | + |
108 | 111 | config.before type: :system, js: true do |
109 | | - driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] |
| 112 | + driven_by :headless_chrome |
| 113 | + end |
| 114 | + |
| 115 | + config.after type: :system, js: true do |
| 116 | + # Force a fresh browser session for each test to prevent state bleeding |
| 117 | + Capybara.send(:session_pool).delete_if { |k, _v| k.include?('headless_chrome') } |
110 | 118 | end |
111 | 119 |
|
112 | 120 | Capybara.disable_animation = true |
|
0 commit comments