Note that there are some explanatory texts on larger screens.

plurals
  1. POBetter logging from Capybara/RSpec?
    text
    copied!<p>I'm having a really tough time investigating the cause of a test failure. I'm a very experienced programmer and am well versed in general debugging techniques, but I'm new to Capybara and RSpec so I'm hoping there's some kind of facility I'm ignorant of that can help me. </p> <p>In short, I have a test something like this:</p> <pre><code>expect { click('.fake_button'); sleep 1 }.to change { clicks.count }.by(1) </code></pre> <p>When the fake button is clicked, it triggers an AJAX call to the Rails app which, among other things, adds a click record to the database. I can think of dozens of things that could be causing this test to fail and have had only limited success getting information out of logs. The tests do not fail in development and it only fails sporadically in test. One of the differences of the test environment is that the tests are run on a server in our office against a server in the cloud, so there are network delays along with other possible issues. </p> <p>This is very hard to diagnose because there's so little information coming out of the failed test and of course all the database information is thrown away by the time I read about the failure. I know <code>clicks.count</code> didn't change in the test and I can infer that <code>click('.fake_button')</code> succeeded, but due to server time sync issues I can't even be sure that the click happened on the right button or that the AJAX call fired. </p> <p>What I'd like are some tools to help me follow this test case in the web server logs (maybe using automatic URL parameters, for example), detailed logging about what Capybara did, and a record of the web page as it was when the failure occurred, including cookie values. Can I get any of that? Anything like that? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload