import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"
import { unstable_dev } from "wrangler"
import type { UnstableDevWorker } from "wrangler"
describe("Worker", () => {
let worker: UnstableDevWorker
beforeAll(async () => {
worker = await unstable_dev("src/worker/index.ts", {
experimental: { disableExperimentalWarning: true },
})
})
afterAll(async () => {
await worker.stop()
})
it("should deny request for invalid paths", async () => {
const cases = {
failures: ["/", "/foo", "/foo/", "/%2F"],
}
for (const path of cases.failures) {
const resp = await worker.fetch(`http://localhost:3000${path}`)
console.log(resp)
expect(resp.status).toBe(404)
}
})
})
import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"
import { unstable_dev } from "wrangler"
import type { UnstableDevWorker } from "wrangler"
describe("Worker", () => {
let worker: UnstableDevWorker
beforeAll(async () => {
worker = await unstable_dev("src/worker/index.ts", {
experimental: { disableExperimentalWarning: true },
})
})
afterAll(async () => {
await worker.stop()
})
it("should deny request for invalid paths", async () => {
const cases = {
failures: ["/", "/foo", "/foo/", "/%2F"],
}
for (const path of cases.failures) {
const resp = await worker.fetch(`http://localhost:3000${path}`)
console.log(resp)
expect(resp.status).toBe(404)
}
})
})