|
| 1 | +import { resolve } from "path"; |
| 2 | +import { fetch } from "undici"; |
| 3 | +import { describe, it } from "vitest"; |
| 4 | +import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived"; |
| 5 | + |
| 6 | +const basePath = resolve(__dirname, ".."); |
| 7 | + |
| 8 | +describe("'wrangler dev' correctly renders pages", () => { |
| 9 | + it("uses the generated config", async ({ expect, onTestFinished }) => { |
| 10 | + const { ip, port, stop } = await runWranglerDev(basePath, [ |
| 11 | + "--port=0", |
| 12 | + "--inspector-port=0", |
| 13 | + ]); |
| 14 | + onTestFinished(async () => await stop?.()); |
| 15 | + |
| 16 | + // Note that the local protocol defaults to http |
| 17 | + const response = await fetch(`http://${ip}:${port}/`); |
| 18 | + const text = await response.text(); |
| 19 | + expect(response.status).toBe(200); |
| 20 | + expect(text).toMatchInlineSnapshot(`"Generated: true"`); |
| 21 | + }); |
| 22 | + |
| 23 | + it("uses a the config from command line rather than generated config", async ({ |
| 24 | + expect, |
| 25 | + onTestFinished, |
| 26 | + }) => { |
| 27 | + const { ip, port, stop } = await runWranglerDev(basePath, [ |
| 28 | + "-c=wrangler.toml", |
| 29 | + "--port=0", |
| 30 | + "--inspector-port=0", |
| 31 | + ]); |
| 32 | + onTestFinished(async () => await stop?.()); |
| 33 | + |
| 34 | + // Note that the local protocol defaults to http |
| 35 | + const response = await fetch(`http://${ip}:${port}/`); |
| 36 | + const text = await response.text(); |
| 37 | + expect(response.status).toBe(200); |
| 38 | + expect(text).toMatchInlineSnapshot(`"Generated: undefined"`); |
| 39 | + }); |
| 40 | +}); |
0 commit comments