What does “HTTP request failed” mean in an rspec/capybara/poltergeist/phantomjs spec?
-
20-12-2019 - |
سؤال
Even when all tests are passing, I see many many instances of this message amid the successful test output:
...
in the single-post view
behaves like editing a comment
HTTP request failed.
HTTP request failed.
HTTP request failed.
...
What is causing it?
المحلول
One possibility is that requests made by for example third-party analytics scripts on your page are failing.
You can see their activity by inspecting the output of poltergeist's page.driver.network_traffic
at the end of a test.
If you think this is the problem, you could take those scripts out of the picture by
- including them in the page only if you're not running tests, or
- using poltergeist's
page.execute_script
to replace appropriate functions in those third-party scripts with no-op functions. (That takes more work but leaves the page contents more production-like, which might catch a few more possible errors.)
لا تنتمي إلى StackOverflow