(
path: string,
options: RequestInit = {},
)
| 120 | } |
| 121 | |
| 122 | async function fetchSimulatorBlob( |
| 123 | path: string, |
| 124 | options: RequestInit = {}, |
| 125 | ): Promise<Blob> { |
| 126 | const { headers, ...rest } = options; |
| 127 | const response = await fetch(apiUrl(path), { |
| 128 | ...rest, |
| 129 | headers: apiHeaders(headers), |
| 130 | }); |
| 131 | if (!response.ok) { |
| 132 | const contentType = response.headers.get("content-type") ?? ""; |
| 133 | if (contentType.includes("application/json")) { |
| 134 | const body = (await response.json()) as { error?: string }; |
| 135 | throw new Error( |
| 136 | body.error ?? `Request failed with status ${response.status}`, |
| 137 | ); |
| 138 | } |
| 139 | throw new Error( |
| 140 | (await response.text()) || |
| 141 | `Request failed with status ${response.status}`, |
| 142 | ); |
| 143 | } |
| 144 | return response.blob(); |
| 145 | } |
| 146 | |
| 147 | export function captureSimulatorScreenshot( |
| 148 | udid: string, |
no test coverage detected