(page: Page)
| 3 | import { coderPort, gitAuth } from "./constants"; |
| 4 | |
| 5 | export const beforeCoderTest = (page: Page) => { |
| 6 | page.on("console", (msg) => { |
| 7 | const location = msg.location(); |
| 8 | // Filters out a bunch of junk warnings the browser produces. |
| 9 | if (!location.url) { |
| 10 | return; |
| 11 | } |
| 12 | // Filters out the gigantic CODER logo we print on every page load, as well |
| 13 | // as some other noise. |
| 14 | if (msg.type() === "info") { |
| 15 | return; |
| 16 | } |
| 17 | console.info(`[console][${msg.type()}] ${msg.text()}`); |
| 18 | }); |
| 19 | |
| 20 | page.on("response", async (response) => { |
| 21 | // Don't log responses for static assets. |
| 22 | if (!isApiCall(response.url())) { |
| 23 | return; |
| 24 | } |
| 25 | // Don't log successful responses. Those are almost always less interesting. |
| 26 | if (response.ok()) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | let responseText: string; |
| 31 | try { |
| 32 | responseText = await response.text(); |
| 33 | responseText = responseText.replaceAll("\n", ""); |
| 34 | } catch { |
| 35 | responseText = "<n/a>"; |
| 36 | } |
| 37 | |
| 38 | console.info( |
| 39 | `[response] url=${response.url()} status=${response.status()} body=${responseText}`, |
| 40 | ); |
| 41 | }); |
| 42 | |
| 43 | page.on("popup", async (popup) => { |
| 44 | console.info(`[popup] url=${popup.url()}`); |
| 45 | }); |
| 46 | |
| 47 | page.on("pageerror", async (error) => { |
| 48 | console.error("[pageerror]", error); |
| 49 | }); |
| 50 | |
| 51 | page.on("crash", async (page) => { |
| 52 | console.error("[crash]", page.url()); |
| 53 | }); |
| 54 | }; |
| 55 | |
| 56 | export const resetExternalAuthKey = async (context: BrowserContext) => { |
| 57 | // Find the session token so we can destroy the external auth link between tests, to ensure valid authentication happens each time. |
no test coverage detected