-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I'm trying to use this to test my retry fetch util, but it doesn't seem to be working. I can see the timeout is being called, but it doesn't seem to timeout the request. Do you know if this is possible to test?
Code
const {timeout = 10000} = options;
const controller = new AbortController();
const id = setTimeout(() => {
controller.abort();
}, timeout);
res = await fetch(url, {
...options,
signal: controller.signal
});
clearTimeout(id);
Test
let called = 0;
mf.mock("GET@/api/hello/:name", async (_req: Request, params: any) => {
if (called++ === 0) {
await sleep(2);
return new Response();
}
return new Response(`Hello, ${params["name"]} ${called}!`, {
status: 200,
});
});
const res = await retryFetch("https://localhost:1234/api/hello/SeparateRecords", {timeout: 1000});
assertEquals(2, called);
assertEquals('Hello, SeparateRecords 2!', await res.text());
Metadata
Metadata
Assignees
Labels
No labels