-
Notifications
You must be signed in to change notification settings - Fork 607
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
Inconsistent handling of script errors between the three engines #731
Comments
@AkA84 thank you very much for doing this comparison! The current intended puppeteer behavior is supposed to throw an @krisdigital — 👆 any ideas here? |
@krisdigital — thank you so much! Will follow up soon. |
The puppeteer version is now fixed on @latest. The error messages are also being sent to the front end -- now I just need to add this information to the layout.
|
@garris @krisdigital i installed the latest version (v3.2.12) and run those 3 scenarios again, and now backstop (with puppeteer) exits as soon as an error is encountered COMMAND | Executing core for `reference`
createBitmaps | Selected 3 of 3 scenarios.
CREATING NEW REFERENCE FILE
Browser Console Log 0: JSHandle:BackstopTools have been installed.
x Close Browser
CREATING NEW REFERENCE FILE
Browser Console Log 0: JSHandle:BackstopTools have been installed.
Puppeteer encountered an error while running scenario "Google / Wait for wrong selector"
Error: waiting for selector ".does-not-exist" failed: timeout 1000ms exceeded
COMMAND | Command `reference` ended with an error after [3.799s]
COMMAND | TypeError: Cannot read property 'join' of undefined
at processScenarioView (node_modules/backstopjs/core/util/runPuppet.js:252:151)
at <anonymous> I noticed that the line referenced in the error is this one const testPair = engineTools.generateTestPair(config, scenario, viewport, variantOrScenarioLabelSafe, scenarioLabelSafe, 0, `${scenario.selectors.join('__')}`);
{
label: 'Google / Wait for wrong selector',
url: 'https://google.com',
onReadyScript: 'wait-for-wrong-selector.js',
sIndex: 1
} |
@AkA84 @garris I think that error was introduced here ddce7a5#diff-2b0d3e4bf62b40b86f9b984a5f9003ecR252 |
Thank you for finding this! I will fix this ASAP. |
@garris (and @krisdigital ) everything works great now, thanks! |
@AkA84 ah, so did you You are allowed to check for (and approve) selectors not being available. |
@garris no i've never approved any report in any of the tests i did as part of this issue, that's why i'm reporting this as a bug. I think the behaviour should be the one displayed in your screenshot and the one that Chromy has (with the due differences)
otherwise imho this could be even worse than it was before: if before you knew the total number of scenarios you could quickly see that the number reported on was not right, now you can't even do that ! You basically have to scroll down yourself and see if there are any errors reported (= you can't trust the report) And I'm not even considering the scenario where you are running backstop as part of a CI process where none of the two options are even possible :/ |
Did you run |
@garris Does this mean that I would need to check all my screenshots manually? We are a relatively large project and currently having 100+ scenarios to run, we cannot really afford checking each reference screenshot to be valid. I think it would make sense to just show the scenario fail if:
Please let us know what do you think. |
@garris I think I understand where we are diverging with our opinions on how things should work. The way we use backstop (the first time, at least) in our project is to first run directly Instead, if I understand correctly, the way you expect it to be used is to run directly I see two possible problems with the latter approach (on the assumption that I got you right)
Last point I though worth discussing was
But wouldn't it be odd to rely on a scenario with a failing script to check whether a selector is available or not? Shouldn't backstop encourage devs, in that case, to write a successful script that check if a selector doesn't exist, instead of using a failing script that expect a selector to exist? Also please note that this is not simply about a selector existing or not, it's about any script error. For example in changed my module.exports = async engine => {
// ...
await engine.nonExistingMethod('.does-not-exist', { timeout: 1000 }); // <---
} And I tried one last thing: to have, for the same scenario, one error thrown for // when running "reference"
module.exports = async engine => {
// ...
await engine.nonExistingMethod('.does-not-exist', { timeout: 1000 });
}
// when running "test"
module.exports = async engine => {
// ...
await engine.waitFor('.does-not-exist', { timeout: 1000 });
} and backstop still passed the comparison, reporting only on the second error but this means that then a scenario with a failing script will always be pass comparison as long as the script keeps failing, no matter what the reason for the failure is (could be a non-existent selector, a wrong method, internal engine error, etc) |
I understand your thinking — however, this has not been a primary use case as of yet. That said — i think this is a useful feature and it would be very easy to add. How about, at the end of a Or maybe simpler for you on the CI side, you could just grep for error messages that pop up during the run and decide specifically what kinds of things you want to check for. Do any of these sound good for you? |
@garris Thanks a lot for the reply, I think we should still allow The issue is that the test remains to be considered as passed, while there are errors - it failed, test is not working. |
@igorpavlov Sure, So then you would want |
Thanks @garris for your reply! If by adding that
Does that match what you had in mind for the |
Yes. That is very specifically exactly what I was thinking. |
(This is with
backstopjs@3.2.9
)I noticed an inconsistency with how the three engines handle script errors, with Puppeteer being the one more troublesome, imho.
I came up with this setup, which you can use to replicate the issue:
Three scenarios, one of which is designed to fail
For the two scenarios with the "onReady" script, there is a variation of the script for each of the engines
Casper
Chromy
Puppeteer
Now
backstop reference
andbackstop test
are run with all three engines, and these are the results that I've foundCasper
With CasperJS the script error makes the entire command immediately fail and exit, meaning that BackstopJS can't capture the remaining screenshots in the list.
Given that
reference
fails, there's no point in runningtest
given that it will fail as well and no report will be generatedChromy
Chromy marks the task as successful and doesn't report any error whatsoever, although the screenshot for "Google / Wait for wrong selector" had not been generated
Running
test
gives the same output, but it's marked as failed. This isreport
's outcomeNow
report
reports on theWaitTimeoutError
and it fails, showing in the html report the missing screenshot for "Google / Wait for wrong selector"Puppeteer
While it reports that something went wrong with a script (which is good for debugging), Puppeteer still allows for the entire test suite to run, and the
report
command is marked as successfulRunning
test
gives the same output, and it's marked as successful as well. This isreport
's outcomeThere is no mentioning whatsoever of "Google / Wait for wrong selector" which at this point is simply ignored,
report
is marked as successful and the html report shows that everything is fine...but with only 2 screenshots instead of 3While CasperJS is too eager to stop everything as soon as it finds an error, Puppeteer's handling of script errors imho is worse as it simply marks the whole run as successful even if there are screenshots missing. If you have a big test suite (we have 120+ screenshots in our project), it's very easy to trust the report and not realize that some screenshots might be missing.
I think the best behaviour should be a mix of Chromy + Puppeteer: show the script error in the output for debugging purposes, let the command run to completion and then mark
test
/report
as failed and show the missing screenshot(s) in the reportThe text was updated successfully, but these errors were encountered: