-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[Question] Fail on unhandled exception? #16355
Comments
I figured out a way to do this. Not sure if it's good practice or not. I run this as the first line of the test. The key is to wait for the error message, but not with an
The strings in expect/to-be were just a way to have something meaningful in the report (Expected: "Error bar not to show up" Received: "But it did"). I would rather have a more semantic way to fail the test, e.g. |
Urgh. This only works for the failure case. If the test "passes", playwright complains that "Target closed" while still waiting for something. |
OK I found Was nice chatting to me : ) |
Closing per above 😄 😁 Yes, |
@rwoll @dgozman @mxschmitt would the Playwright team consider adding a config option for failing on error to Playwright? I'm aware that the following code achieves "failing on error" to add to every test (also multiple tests at once via overriding the page fixture), but I think this would be widespread enough that some option like page.on('pageerror', (error) => {
throw error;
}); References: Prior Art / Similar
|
If an unhandled JS exception happens in the browser, i.e. an error that would show up in the devtools console, does that cause the current test to fail?
If not, is there a way to make that happen?
Alternatively, I have a "something went wrong" error indicator that pops up in the UI. I know how to write an assertion that says the error indicator is not present, but that only applies at a particular moment in the test script.
Say I'm waiting for some action to complete, I also want to be watching to see if the error appears, and fail the test if it does. How can I code that? e.g. "wait for X to be visible" and simultaneously "fail if Y becomes visible"
Thanks
The text was updated successfully, but these errors were encountered: