Duan Jiaming
Duan Jiaming

Reputation: 1

How to intercept a request on time basis in cypress

I have a request that will be called every 5 seconds, I can use intercept to capture it and count how many times it has been called, but is there a way I can tell how often it has been called?

Upvotes: 0

Views: 74

Answers (1)

Depends on what you have in the intercept. If you use a routeHandler function, it's easy to record the call time in an array

const calls = []
calls.push(Date.now())  // start

intercept(url, (req) => {
  calls.push(Date.now())  // each call
})

Upvotes: 2

Related Questions