Closed jesus-dayo closed 1 year ago
I think you should be able to use a sleep
before returning, right? This is the function I use to be able to await sleep(500)
for example:
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
For example , the code below I would like to use a delay property to simulate a slow response
fetchMocker.mockIf(/http:\/\/[^/]+:?\d*\/api\/slow/, async (req) => { if (req.method === 'DELETE') { return { body: '{"data":{"id":"a12345"}}', headers: { 'X-Some-Response-Header': 'Some header value', }, **delay: 2000,** } } } )
I am unable to find anything in the docs related to this.