MCPcopy Index your code
hub / github.com/coder/coder / beforeCoderTest

Function beforeCoderTest

site/e2e/hooks.ts:5–54  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

3import { coderPort, gitAuth } from "./constants";
4
5export 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
56export 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.

Calls 4

isApiCallFunction · 0.85
infoMethod · 0.80
statusMethod · 0.80
urlMethod · 0.65

Tested by

no test coverage detected