File
Blob: vitest.config.ts
| 1 | import { fileURLToPath, URL } from "node:url"; |
| 2 | import { defineConfig, defineProject } from "vitest/config"; |
| 3 | |
| 4 | import { cloudflareWorkerPlugin } from "./tests/vitest/cloudflare.ts"; |
| 5 | |
| 6 | const srcDirectory = fileURLToPath(new URL("./src", import.meta.url)); |
| 7 | const testsDirectory = fileURLToPath(new URL("./tests", import.meta.url)); |
| 8 | |
| 9 | const aliases = { |
| 10 | "@": srcDirectory, |
| 11 | "@tests": testsDirectory, |
| 12 | }; |
| 13 | |
| 14 | export default defineConfig(() => { |
| 15 | return { |
| 16 | test: { |
| 17 | projects: [ |
| 18 | defineProject({ |
| 19 | resolve: { alias: aliases }, |
| 20 | test: { |
| 21 | name: "shared", |
| 22 | include: ["tests/shared/**/*.test.ts"], |
| 23 | }, |
| 24 | }), |
| 25 | defineProject({ |
| 26 | resolve: { alias: aliases }, |
| 27 | test: { |
| 28 | name: "sites", |
| 29 | include: ["tests/sites/**/*.test.ts", "tests/sites/**/*.test.tsx"], |
| 30 | }, |
| 31 | }), |
| 32 | defineProject({ |
| 33 | resolve: { alias: aliases }, |
| 34 | test: { |
| 35 | name: "client", |
| 36 | include: ["tests/client/**/*.test.ts", "tests/client/**/*.test.tsx"], |
| 37 | exclude: ["tests/client/**/*.dom.test.ts", "tests/client/**/*.dom.test.tsx"], |
| 38 | }, |
| 39 | }), |
| 40 | defineProject({ |
| 41 | resolve: { alias: aliases }, |
| 42 | test: { |
| 43 | name: "client-dom", |
| 44 | include: ["tests/client/**/*.dom.test.ts", "tests/client/**/*.dom.test.tsx"], |
| 45 | environment: "jsdom", |
| 46 | environmentOptions: { jsdom: { url: "http://127.0.0.1/" } }, |
| 47 | }, |
| 48 | }), |
| 49 | defineProject({ |
| 50 | resolve: { alias: aliases }, |
| 51 | test: { |
| 52 | name: "worker-unit", |
| 53 | include: ["tests/worker/**/*.test.ts"], |
| 54 | exclude: ["tests/worker/**/*.workers.test.ts"], |
| 55 | }, |
| 56 | }), |
| 57 | defineProject({ |
| 58 | plugins: [cloudflareWorkerPlugin()], |
| 59 | resolve: { alias: aliases }, |
| 60 | test: { |
| 61 | name: "worker-runtime", |
| 62 | isolate: false, |
| 63 | fileParallelism: false, |
| 64 | sequence: { groupOrder: 1 }, |
| 65 | include: ["tests/worker/**/*.workers.test.ts"], |
| 66 | setupFiles: ["./tests/setup/worker.ts"], |
| 67 | // Worker runtime cold-start can exceed vitest's 5s default for the |
| 68 | // first request that hits a given handler family. |
| 69 | testTimeout: 30_000, |
| 70 | }, |
| 71 | }), |
| 72 | ], |
| 73 | }, |
| 74 | }; |
| 75 | }); |