|
| 1 | +import { test, expect } from "@playwright/test"; |
| 2 | +import { describe } from "node:test"; |
| 3 | + |
| 4 | +test.describe("instrumentation", () => { |
| 5 | + test("the instrumentation register hook should work for the nodejs runtime", async ({ page }) => { |
| 6 | + const res = await page.request.get("/api/hello"); |
| 7 | + const respJson: Record<string, string> = await res.json(); |
| 8 | + expect(respJson["nodejs-instrumentation-setup"]).toEqual( |
| 9 | + "this value has been set by calling the instrumentation `register` callback in the nodejs runtime" |
| 10 | + ); |
| 11 | + }); |
| 12 | + |
| 13 | + test("the instrumentation register hook should work for the edge runtime", async ({ page }) => { |
| 14 | + const res = await page.request.get("/middleware"); |
| 15 | + const respJson: Record<string, string> = await res.json(); |
| 16 | + expect(respJson["edge-instrumentation-setup"]).toEqual( |
| 17 | + "this value has been set by calling the instrumentation `register` callback in the edge runtime" |
| 18 | + ); |
| 19 | + }); |
| 20 | + |
| 21 | + // Note: we cannot test this since currently both runtimes share the same global scope |
| 22 | + // (see: https://github.com/opennextjs/opennextjs-cloudflare/issues/408) |
| 23 | + describe.skip("isolation", () => { |
| 24 | + test("the instrumentation register hook nodejs logic should not effect edge routes", async ({ page }) => { |
| 25 | + const res = await page.request.get("/middleware"); |
| 26 | + const respJson: Record<string, string> = await res.json(); |
| 27 | + expect(respJson["nodejs-instrumentation-setup"]).toEqual("undefined"); |
| 28 | + }); |
| 29 | + |
| 30 | + test("the instrumentation register hook edge logic should not effect nodejs routes", async ({ page }) => { |
| 31 | + const res = await page.request.get("/api/hello"); |
| 32 | + const respJson: Record<string, string> = await res.json(); |
| 33 | + expect(respJson["edge-instrumentation-setup"]).toEqual("undefined"); |
| 34 | + }); |
| 35 | + }); |
| 36 | +}); |
0 commit comments