I need to validate that my app has invoked specifi...
# help
p
I need to validate that my app has invoked specific API calls to an event endpoint, and validate some amount of the data in the request. In the case of a single API call I'd use
cy.intercept()
with an alias, call
cy.wait()
and assert the
request.body
contains the expected data. Works perfectly for a single request, or even a series of requests as long as the API calls are made in the same order every single time. However, in many cases the app invokes a half dozen or more API calls to the event endpoint and the order the API calls are completed are not guaranteed. I need some manner to assert the expected calls have been made, but without having to pop my way through the interception stack in a specific order. Thoughts/ideas?
The intercept alias apparently has a stack and when you call
cy.get("@alias")
it pops the intercepted requests from the stack. I guess I really just need to access the entire stack as a single object that I can assert against and then clear the stack once I'm done asserting. Or something like that.
Alternatively I can simply query the database the events are written to, though it'd seem easier and more convenient to assert against the intercepted requests.