Skip to content

Is there a default delay applied to resonses? #553

Answered by kettanaito
philals asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @philals. Thanks for reaching out.

MSW does not apply any default delay to mocked responses. You can see the default response properties here:

delay: 0,

The random realistic response delay is applied when calling ctx.delay() without arguments when composing your mocked response. Like so:

rest.get('/user', (req, res, ctx) => res(ctx.json(...))) // no delay

rest.post('/book', (req, res, ctx) => res(ctx.delay(), ctx.json(...))) // random realistic delay

rest.delete('/user', (req, res, ctx) => res.(ctx.delay(500), ctx.json(...))) // exact delay duration (500ms)

We have been noticing a bit of lag for MSW to respond to requests.

D…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by kettanaito
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kettanaito
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants