MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / mockNetwork

Function mockNetwork

tests/mocks/network.ts:23–33  ·  view source on GitHub ↗
({ onSend }: { onSend: (request: MockXhrRequest, ...args: any[]) => any })

Source from the content-addressed store, hash-verified

21// const realFetch = fetch;
22
23export const mockNetwork = ({ onSend }: { onSend: (request: MockXhrRequest, ...args: any[]) => any }) => {
24 const mockXhr = newMockXhr();
25 const originalOnSend = onSend || mockXhr.onSend;
26 mockXhr.onSend = function (request, ...args: any[]) {
27 // @ts-ignore
28 const ret = originalOnSend?.apply(this, [request, ...args]);
29 setNetworkRequestCounter(request.url);
30 return ret;
31 };
32 return { mockXhr };
33};

Callers 1

gm_api.test.tsFile · 0.90

Calls 2

setNetworkRequestCounterFunction · 0.85
applyMethod · 0.45

Tested by

no test coverage detected