Closed prashanth-92 closed 11 months ago
Hi @prashanth-92! Thanks for your PR, but unfortunately your change doesn't actually introduce per-request delays. The added method instead sets the delay for all requests, so for example:
mock.delayInMs(200).onGet("/foo").reply(200);
mock.delayInMs(0).onGet("/bar").reply(200);
will cause no delay when a request to /foo
is made.
Hey @ctimmerm, yes my solution is setting the delay in the MockAdapter
directly. So it will work for one endpoint but if you set it again, it will get overridden
Just to see if I get this right, if we need to add it at an endpoint level, then we might need to introduce a state in the handlers per verb and then use delay it with a promise approach you mentioned in one of the comments.
@ctimmerm I have a revised approach with delay per request. Can you please review it?
Ping @ctimmerm If you have some time, please review this pull request
Hey @ctimmerm when you have time, please review this pull request. I would really appreciate it.
Please re-review @ctimmerm
Please re review.
@ctimmerm please review.
@ctimmerm Can you please re review?
I would also be interested to have withDelay()
accept a function. This would allow me to create a function that generates a random delay in a specific range.
I would also be interested to have
withDelay()
accept a function. This would allow me to create a function that generates a random delay in a specific range.
The idea behind this pull request is to give a helper for introducing a delay time alone. Your new feature request can be addressed in another pull request. Feel free to open one.
Hey guys, is this getting merged or nah? I just found a use case where I need a delay for a specific request.
@ctimmerm If there are no concerns, can we merge this PR? I think it will be useful.
hmm, a force push merged this accidentally and can't reopen. I'll merge this manually
hah. reopen button shows up again.
edit: nope. didn't work
Released as v1.22.0
marcbachmann, prashanth-92 - I'm a bit late to the party but there's no documentation and I think the typescript definitions are missing...
Also IMHO the API for this is now unintuitive (it looked like @ctimmerm had a good suggestion). Why the change to make this return the reply function rather than the request handler?
Interested about that too. Need a doc & types up to date plz.
Interested about that too. Need a doc & types up to date plz.
I opened a PR to add types to replyWithDelay https://github.com/ctimmerm/axios-mock-adapter/pull/383
232 Attempts to provide a helper for adding a delay in milliseconds. The test shows a way to use the method.