-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option cliExitOnEngineError to bubble up if engine has an error… #1127
Conversation
Hi @garris, sorry to push but do you think you will merge this PR at some point? Our pipeline is currently being held up by this, and if it is not going to be merged I need to find another way to progress the pipeline (probably by having Jenkins checking the errors folder). |
Hi there @mummybot -- apologies for the delay. I believe backstop is correctly reporting errors in cases where something in a scenario setup goes wrong. Can you help me understand your situation better so we can figure out the right approach? |
Hi, thanks for the reply. It does indeed report errors fine, at both back stop and underlying engine issues. However we're finding that when running in a Jenkins job, which only errors if an exit code of 1 is returned, when running on reference, if there is an engine error such as missing selector, then the backstop job completes with success, albeit there are then error images in the reference folder. We need the ability to fail the backstop job if there are engine errors, so as to fail our build pipeline. A specific case, but hey ho. |
I've uploaded an example of what I have solved: In examples/responsiveDemo SCENARIO > comparePage
SCENARIO > comparePage
BackstopException: comparePage on tablet: TimeoutError: waiting for selector "#missing" failed: timeout 30000ms exceeded
BackstopException: comparePage on phone: TimeoutError: waiting for selector "#missing" failed: timeout 30000ms exceeded
Run `$ backstop test` to generate diff report.
COMMAND | Command "reference" successfully executed in [33.308s]
responsiveDemo $ In examples/responsiveDemoFixed BackstopException: comparePage on tablet: TimeoutError: waiting for selector "#missing" failed: timeout 30000ms exceeded
BackstopException: comparePage on phone: TimeoutError: waiting for selector "#missing" failed: timeout 30000ms exceeded
COMMAND | Command "reference" ended with an error after [31.506s]
COMMAND | [object Object]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev-backstop-reference: `node ../../cli/index.js reference`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev-backstop-reference script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/francis/.npm/_logs/2019-12-09T08_23_40_348Z-debug.log |
Ok. Got it. I understand your thinking here -- but may I ask that we not short-circuit the bitmap generation here. The errors that occur during this flow should still propagate up. Would it be possible for you to handle this the same way that Please let me know if that would be possible. Thanks! |
I'm in London, so will look at this my tonight after work. If I figure out what you are asking, would you still want it as an optional condition, or would you want that as the default functionality? |
Sounds good. This would be an improvement which I don't expect would break existing implementations -- so I am thinking default functionality. |
25985c4
to
e8b6fd5
Compare
e8b6fd5
to
4b485e3
Compare
I added another command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good start. Almost there. Please implement this as an imported utility script as opposed to a new command. See comments -- hopefully this will make sense. Thanks!
core/command/index.js
Outdated
@@ -20,7 +20,8 @@ var commandNames = [ | |||
'test', | |||
'approve', | |||
'version', | |||
'stop' | |||
'stop', | |||
'engineErrors' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to just add this as a regular module (from /core/util
). We should avoid creating this as a command since this would never be run alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/command/reference.js
Outdated
@@ -5,6 +5,7 @@ const { shouldRunDocker, runDocker } = require('../util/runDocker'); | |||
|
|||
module.exports = { | |||
execute: function (config) { | |||
const executeCommand = require('./index'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, agreed
core/command/reference.js
Outdated
@@ -22,6 +23,7 @@ module.exports = { | |||
return createBitmaps(config, true); | |||
}).then(function () { | |||
console.log('\nRun `$ backstop test` to generate diff report.\n'); | |||
return executeCommand('_engineErrors', config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to just run a plain old module. like here... https://github.com/garris/BackstopJS/blob/master/core/command/test.js#L10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/command/engineErrors.js
Outdated
@@ -0,0 +1,13 @@ | |||
module.exports = { | |||
execute: function (config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just export the anon function here. Skip the execute property and the object all together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Added test for engineErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! Thank you.
Can you let me know here when you bump the minor version number so I can pull it in? And thanks for your comments, very helpful. BackstopJS is a great library! |
published to [email protected]
Please validate when you get a chance -- thanks! |
Awesome, I'll try it tomorrow, finished for the night. |
Worked a treat, thank you very much! |
Exposing engine errors
By default if there is an error in the engine e.g. missing selector, it won't exit BackstopJS. This is normally fine as the screenshots will pick up any unexpected differences. If you want to terminate BackstopJS on engine errors set the option flag: