MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / fetchReferenceScreenshotDataUrl

Function fetchReferenceScreenshotDataUrl

scripts/e2e-webrtc-reliability.mjs:92–116  ·  view source on GitHub ↗
(udid)

Source from the content-addressed store, hash-verified

90}
91
92async function fetchReferenceScreenshotDataUrl(udid) {
93 if (!screenshotApiRoot) {
94 return null;
95 }
96 const url = new URL(
97 `/api/simulators/${encodeURIComponent(udid)}/screenshot.png`,
98 screenshotApiRoot,
99 );
100 url.searchParams.set("artifactCheck", Date.now().toString());
101 const headers = screenshotApiToken
102 ? { "x-simdeck-token": screenshotApiToken }
103 : undefined;
104 const response = await fetch(url, {
105 cache: "no-store",
106 headers,
107 });
108 if (!response.ok) {
109 throw new Error(
110 `reference screenshot failed with ${response.status}: ${await response.text()}`,
111 );
112 }
113 const contentType = response.headers.get("content-type") ?? "image/png";
114 const base64 = Buffer.from(await response.arrayBuffer()).toString("base64");
115 return `data:${contentType};base64,${base64}`;
116}
117
118async function waitForDevTools(chromeProcess, getChromeOutput, getSpawnError) {
119 const versionUrl = `http://127.0.0.1:${debugPort}/json/version`;

Callers 1

Calls 7

fetchFunction · 0.85
setMethod · 0.80
toStringMethod · 0.80
fromMethod · 0.80
arrayBufferMethod · 0.80
textMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected