Files
cloudflare--workers-sdk/fixtures/worker-app/tests/https.test.ts
T
wehub-resource-sync 70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:11 +08:00

34 lines
1.0 KiB
TypeScript

import { resolve } from "path";
import { Agent, fetch } from "undici";
import { afterAll, beforeAll, describe, it } from "vitest";
import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived";
describe("'wrangler dev' starts HTTPS server", () => {
let ip: string, port: number, stop: (() => Promise<unknown>) | undefined;
beforeAll(async () => {
({ ip, port, stop } = await runWranglerDev(resolve(__dirname, ".."), [
"--port=0",
"--inspector-port=0",
"--local-protocol=https",
]));
});
afterAll(async () => {
await stop?.();
});
it("allows access over HTTPS", async ({ expect }) => {
const dispatcher = new Agent({
// `wrangler dev` will generate a self-signed certificate. By default,
// Node will reject these. Therefore, we need to use a custom
// dispatcher that accepts "invalid" certificates.
connect: { rejectUnauthorized: false },
});
const response = await fetch(`https://${ip}:${port}/random`, {
dispatcher,
});
expect(response.ok).toBe(true);
});
});