(pathname: string, opts: RequestInit & { noAuth?: boolean } = {})
| 18 | let queueFile: string = ''; |
| 19 | |
| 20 | async function api(pathname: string, opts: RequestInit & { noAuth?: boolean } = {}): Promise<Response> { |
| 21 | const { noAuth, ...fetchOpts } = opts; |
| 22 | const headers: Record<string, string> = { |
| 23 | 'Content-Type': 'application/json', |
| 24 | ...(fetchOpts.headers as Record<string, string> || {}), |
| 25 | }; |
| 26 | if (!noAuth && !headers['Authorization'] && authToken) { |
| 27 | headers['Authorization'] = `Bearer ${authToken}`; |
| 28 | } |
| 29 | return fetch(`http://127.0.0.1:${serverPort}${pathname}`, { ...fetchOpts, headers }); |
| 30 | } |
| 31 | |
| 32 | beforeAll(async () => { |
| 33 | tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sidebar-integ-')); |
no test coverage detected