|
| 1 | +import { ok } from "node:assert/strict"; |
| 2 | +import test from "node:test"; |
| 3 | +import astroDescription from "./webframeworks/astro.ts"; |
| 4 | +import nextDescription from "./webframeworks/next.ts"; |
| 5 | +import nitroDescription from "./webframeworks/nitro.ts"; |
| 6 | + |
| 7 | +test("Nitro template loads LogTape during server startup", async () => { |
| 8 | + const { files } = await nitroDescription.init({ |
| 9 | + projectName: "test-app", |
| 10 | + dir: ".", |
| 11 | + command: "init", |
| 12 | + packageManager: "npm", |
| 13 | + kvStore: "in-memory", |
| 14 | + messageQueue: "in-process", |
| 15 | + webFramework: "nitro", |
| 16 | + testMode: false, |
| 17 | + dryRun: true, |
| 18 | + allowNonEmpty: false, |
| 19 | + }); |
| 20 | + |
| 21 | + ok(files); |
| 22 | + ok("server/plugins/logging.ts" in files); |
| 23 | + const plugin = files["server/plugins/logging.ts"]; |
| 24 | + ok(plugin); |
| 25 | + ok(plugin.includes('import "../logging";')); |
| 26 | +}); |
| 27 | + |
| 28 | +test("Next.js template loads LogTape through instrumentation", async () => { |
| 29 | + const { files } = await nextDescription.init({ |
| 30 | + projectName: "test-app", |
| 31 | + dir: ".", |
| 32 | + command: "init", |
| 33 | + packageManager: "npm", |
| 34 | + kvStore: "in-memory", |
| 35 | + messageQueue: "in-process", |
| 36 | + webFramework: "next", |
| 37 | + testMode: false, |
| 38 | + dryRun: true, |
| 39 | + allowNonEmpty: false, |
| 40 | + }); |
| 41 | + |
| 42 | + ok(files); |
| 43 | + ok("instrumentation.ts" in files); |
| 44 | + const instrumentation = files["instrumentation.ts"]; |
| 45 | + ok(instrumentation); |
| 46 | + ok(instrumentation.includes("export async function register()")); |
| 47 | + ok(instrumentation.includes("process.env.NEXT_RUNTIME")); |
| 48 | + ok(instrumentation.includes('await import("./logging")')); |
| 49 | +}); |
| 50 | + |
| 51 | +test("Astro template loads LogTape through middleware", async () => { |
| 52 | + const { files } = await astroDescription.init({ |
| 53 | + projectName: "test-app", |
| 54 | + dir: ".", |
| 55 | + command: "init", |
| 56 | + packageManager: "npm", |
| 57 | + kvStore: "in-memory", |
| 58 | + messageQueue: "in-process", |
| 59 | + webFramework: "astro", |
| 60 | + testMode: false, |
| 61 | + dryRun: true, |
| 62 | + allowNonEmpty: false, |
| 63 | + }); |
| 64 | + |
| 65 | + ok(files); |
| 66 | + const middleware = files["src/middleware.ts"]; |
| 67 | + ok(middleware); |
| 68 | + ok(middleware.includes('import "./logging.ts";')); |
| 69 | +}); |
0 commit comments