test-vitest-new-worker.js 547 B

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