MCPcopy
hub / github.com/axios/axios / waitForRequest

Function waitForRequest

tests/browser/adapter.browser.test.js:65–78  ·  view source on GitHub ↗
(timeoutMs = 1000)

Source from the content-addressed store, hash-verified

63const sleep = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms));
64
65const waitForRequest = async (timeoutMs = 1000) => {
66 const start = Date.now();
67
68 while (Date.now() - start < timeoutMs) {
69 const request = requests.at(-1);
70 if (request) {
71 return request;
72 }
73
74 await sleep(0);
75 }
76
77 throw new Error('Expected an XHR request to be sent');
78};
79
80describe('adapter (vitest browser)', () => {
81 beforeEach(() => {

Callers 1

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected