Reputation: 701
I'm using Rspec/Capybara with Poltergeist as a driver to write tests for some large web applications.
My issue is that I would like to record the messages that appear on the console, but so far I've been unable to do so.
I am aware of the options js_errors
and phantomjs_logger
, but I have had some issues with them:
js_errors: false
, the file I specify in phantomjs_logger
stays empty;js_errors: true
, console.log
messages are logged in the file specified in phantomjs_logger
, but then almost all my specs fail because of
javascript errors that may not even be relevant to the navigation example I'm testing.Any idea on how I can save the console messages while not breaking specs on every js error?
CLARIFICATION: I have no control over the development, my task is to check the stability of the whole stack of the applications in the various environments, accessing from the front-end, so clearing out all the javascript errors is out of the question. The specs I'm writing are also supposed to ignore javascript errors if they don't impair the usage of the interface.
Upvotes: 2
Views: 2171
Reputation: 49870
You can't. The PhantomJS client catches javascript error messages and adds them to an array. Then when a command completes, if js_errors == true, that array is checked and if not empty the javascript errors are returned and trigger an error in the test. There is no other API in poltergeist for accessing those errors. It sounds like you need to have a discussion with your manager about the wisdom of just ignoring JS errors if they apparently don't impair usage - it's a potentially dangerous development practice
Upvotes: 5