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

Function waitForRequest

tests/browser/interceptors.browser.test.js:108–121  ·  view source on GitHub ↗
(timeoutMs = 1000)

Source from the content-addressed store, hash-verified

106const sleep = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms));
107
108const waitForRequest = async (timeoutMs = 1000) => {
109 const start = Date.now();
110
111 while (Date.now() - start < timeoutMs) {
112 const request = requests.at(-1);
113 if (request) {
114 return request;
115 }
116
117 await sleep(0);
118 }
119
120 throw new Error('Expected an XHR request to be sent');
121};
122
123describe('interceptors (vitest browser)', () => {
124 beforeEach(() => {

Callers 3

fireRequestFunction · 0.70
fireRequestCatchFunction · 0.70

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected