Closed alexthewilde closed 7 years ago
I would rather not expose those methods, I can easily see someone else (or myself) refactoring that code without realising why it's like that.
Perhaps a more explicit way to achieve this would be to provide a config option like
var flow = require('../phantomflow').init({
debug: 1,
ignoreResourceErrors: true
});
Thanks @jamescryer for looking into this. I don't really want to ignore errors per se, but rather filter them the way I need it. Thus to me an exposed method that I can override makes more sense.
Closing as this solution would add a maintenance cost to the project. Makes perfect sense in a OSS environment to keep this on fork/branch.
@alexthewilde, you might look into using casper's removeAllListeners function in your test setup. We do something like this to replace the default onResourceError handling in test setup:
casper.clear().
removeAllListeners('resource.error').
on('resource.error', function (resourceError) {
console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');
console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
});
See also this post.
@eskitek thanks a bunch!
Factor debug event listener closure functions into named functions so they can be removed using casper.removeListener() if needed.
In my case I want to suppress "Resource Error" debug logs which occur every time a page location changes while image resource haven't finished loading yet.