Skip to content
Advertisement

How to add regular expression to filter out the xhr URL in Cypress

I have a scenario where in I have to process and validate the XHR response of nearly equal URLs:

JavaScript

when I initialize the server in cypress and mention the xhr url as following, it always returns me the response of the URL-1 (which in my case is called first by the AUT) but I am unable to fetch the response of URL-2 although it is called in the AUT.

JavaScript

I want to capture the response of URL-2. Please suggest any approach to do so (preferably regEx)

Advertisement

Answer

The above solution works for a wild card search criteria but not for specific api search. Using something like this can help you sort out the request

JavaScript
Advertisement