Running test code after every page load #17162
Unanswered
mateuszdrwal
asked this question in
Questions and Help
Replies: 2 comments 2 replies
-
Did you ever find a solution to this? I need to do almost exactly the same thing |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hello, eg.
and then call your visit
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, we are testing a PHP app using cypress and would like to make cypress fail the current test if it detects a PHP error on the page. Because we are using xdebug all PHP errors contain the class
.xdebug-error
, so detecting the error itself is as simple ascy.get('.xdebug-error').should('not.exist')
. The problem is that with this solution we have to place this code after every cy.visit, form submit etc. which is easy to forget and reduces the code quality of the tests. Ideally the check would run automatically after every page load. We have tried running the following code on cypress init, but it throws this error with a not very helpful (in this case) message:The same happens with the
onLoad
option tocy.visit()
. I assume this is because you are not supposed to be able to queue asynchronous test code in events by runningcy
methods, or maybe I'm just doing it wrong. Even if the above code block is "completely wrong" with regard to how cypress works, I think it illustrates what we want to do pretty well. Is there some way to do that? Or maybe there is a better way to check for PHP errors in the first place without adding a bunch of test code after every page load?Beta Was this translation helpful? Give feedback.
All reactions