Open capaj opened 1 year ago
Looking at mock-interceptors.js and mock-util.js classes, the default behavior for intercept().reply() is not to persist and also discard the intercept after matching one request. However, it does support "persist" and "times" options:
mockPool.intercept({ path: '/foo' , }).reply(200, 'foo').persist() //the intercept can get matched unlimited times
mockPool.intercept({ path: '/foo' , }).reply(200, 'foo').times(10) //the intercept gets discarded after matching 10 requests
Since there could be various different reasons an intercept match is not found (including discarded earlier matches for path, method, headers etc), it's hard to give a useful quantitative error message. Given that there is no documentation for these reply options, I suggest we add documentation for "times" and "persist" and link to them as part of error message. I'll create a PR.
I will create a PR for updating documentation.
This would solve...
The implementation should look like...