test-vitest-new-worker.ts 617 B

12345678910111213141516171819202122232425
  1. import { unstable_dev } from "wrangler";
  2. import type { UnstableDevWorker } from "wrangler";
  3. import { describe, expect, it, beforeAll, afterAll } from "vitest";
  4. describe("Worker", () => {
  5. let worker: UnstableDevWorker;
  6. beforeAll(async () => {
  7. worker = await unstable_dev("src/index.ts", {
  8. experimental: { disableExperimentalWarning: true },
  9. });
  10. });
  11. afterAll(async () => {
  12. await worker.stop();
  13. });
  14. it("should return Hello World", async () => {
  15. const resp = await worker.fetch();
  16. if (resp) {
  17. const text = await resp.text();
  18. expect(text).toMatchInlineSnapshot(`"Hello World!"`);
  19. }
  20. });
  21. });