Conflict with `bottleneck` library?
GeoffThorpeFT opened this issue · 1 comments
We have been using fetch-mock-jest to test that our client library is being called - and being called the right number of times with the expected parameters.
It was working perfectly when our client library, which contains rate limiting, was using the p-ratelimit
library.
However, when we move to the bottleneck
rate limiting library we see testing errors.
Previously when we ran the following test we would see that the url
had been called:
mockFetch.patch(url, 200);
lockPatch(type, code, payload, query);
expect(mockFetch.called(url)).toBe(true);
Now, when bottleneck
is being used we get a false
response to the called(url)
check.
Further. inspection of the mockFetch
results - by using the calls()
function - indicates that p-ratelimit
allows a full set of expected url calls to be recorded whereas bottleneck
causes the url list to be empty.
We have included logging commands in our current library and can confirm both p-ratelimit
and bottleneck
DO both run the same set url fetch requests.
Not a conflict. More of a misunderstanding of how to check the result of an async test. lockPatch
requires an await
😄
Wonder how the test worked up to this point 😱