timing of Capybara.reset_sessions! in system specs (and integration with capybara-screenshot)

14 views
Skip to first unread message

Tim Diggins

unread,
Apr 22, 2022, 8:08:02 AM4/22/22
to rspec
I've been trying to get capybara-screenshot integrated with rails projects using system specs and it has been really tricky. It worked fine with feature specs.

I've done quite a lot of reading and my understanding of the problem is that capybara screenshot is attaching information about the screenshot in an after lifecycle hook and then trying to format that in a custom notifier (after_failure) . 

But the system specs are causing the Capybara.reset_sessions! to occur in between these, because the after_teardown (minitest/rails) hook is being called during the after lifecycle hook.

However in other (non-system) specs the after_teardown hook occurs after all the arounds (and the after_failure notifications I believe) as part of an around hook.

There was no other way to do this with Rails 5.2 and below because the after_teardown was where the (rails) take_screenshot happened. As of Rails 6.0 this occurs in before_teardown, and we could thus fix this and make the rails-initiated Capybara.reset_sessions! happen later in the lifecycle.

What do you think? 

Reply all
Reply to author
Forward
0 new messages