TLDR: This card explains which threads and processes interact with each other when you run a Selenium test with Capybara. This will help you understand "impossible" behavior of your tests.
When you run a Rack::Test (non-Javascript) test with Capybara, there is a single process in play. It runs both your test script and the server responding to the user interactions scripted by your test.
A Selenium (Javascript) test has a lot more moving parts:
cucumber
.Most of the time, Capybara/Selenium will hide that complexity from you. But sometimes the complexity will bleed through, causing your tests to show "impossible" behavior.
Here is some unexpected behavior caused by the interaction of threads and processes:
wait_until
or our patiently
helper.page.execute_script
and immediately inspect the result in a debugger shell. You need to wait_until
the AJAX request completes before launching the debugger.wait_until
the AJAX request completes before launching the debugger.Timecop
), the time will remain unchanged for your scripted browser window. Use a solution like timemachine instead.