'How to skip JavaScript error while running Cypress tests
Problem - I am getting "503 Service Temporarily Unavailable" while running my cypress test. The application that I am testing is a 3rd party application and there is a javascript error on one of the pages. I want to continue my test and want to skip the JS error on the page I am testing. I tried to "Uncaught Exception", link https://docs.cypress.io/api/events/catalog-of-events.html#Examples but it is not helping me out. I am still getting "503 Service Temporarily Unavailable". Any Idea how to solve this problem? enter image description here
In testCafe it is done via https://devexpress.github.io/testcafe/documentation/reference/configuration-file.html#skipjserrors So just checking is there a way for Cypress to handle this problem.
Cypress Version 6.4.0
Solution 1:[1]
"503 Service Temporarily Unavailable" is caused by your page reaching out to a server and not getting the expected response.
Here's the MDN description
The HyperText Transfer Protocol (HTTP) 503 Service Unavailable server error response code indicates that the server is not ready to handle the request.
The best approach is to use cy.intercept() to catch the call to the server and stub the response with something that the app can use.
Take a look at the Network tab in devtools to try and find the call that's causing the problem, and what it should be delivering. This will tell you what you need to provide in the mock.
Please don't use Cypress.on('uncaught:exception' to mask the error.
This will mask all errors including others not related to the 503 that you should report as part of the testing.
At least if you are going to use it, use Cypress.once('uncaught:exception' which will just ignore a single error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
