'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?



Solution 1:[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
})

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 SuchAnIgnorantThingToDo-UKR