MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / installMocks

Function installMocks

host/tests/host.test.js:63–78  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

61 /* Per-case mocks; uninstalled after each case so they don't leak into later ones. */
62 const httpMocks = [];
63 const installMocks = async (c) => {
64 for (const m of c.http_mocks ?? []) {
65 const handler = (route) => route.fulfill({
66 status: m.status ?? 200,
67 contentType: m.contentType ?? "application/json",
68 body: m.body ?? "",
69 });
70 await page.route(m.url, handler);
71 httpMocks.push({ url: m.url, handler });
72 }
73 for (const m of c.ws_mocks ?? []) {
74 await page.routeWebSocket(m.url, (ws) => {
75 if (m.echo) ws.onMessage((message) => ws.send(message));
76 });
77 }
78 };
79 const uninstallMocks = async () => {
80 for (const { url, handler } of httpMocks.splice(0)) await page.unroute(url, handler);
81 };

Callers 1

runCapabilityFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected