hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import path from "node:path"; |
| 2 | import solid from "vite-plugin-solid"; |
| 3 | import { defineConfig } from "vitest/config"; |
| 4 | |
| 5 | const alias = { "@": path.resolve(__dirname, "./src") }; |
| 6 | // Live-backend suite, run separately: `bun run test:contract`. |
| 7 | // nav-items.test.ts is a plain .ts file but asserts on nav entries that carry |
| 8 | // Solid components, so it runs in the dom project (see its include) — the node |
| 9 | // project excludes it instead. |
| 10 | const exclude = ["**/node_modules/**", "**/dist/**", "src/api/__tests__/contract/**"]; |
| 11 | |
| 12 | /** |
| 13 | * Two projects, one `vitest run`: plain logic/API tests stay on the fast node |
| 14 | * environment with no Solid transform, component tests (`*.test.tsx`) get jsdom |
| 15 | * plus vite-plugin-solid. The split is by file extension so neither side can |
| 16 | * accidentally pull the other's environment. |
| 17 | */ |
| 18 | export default defineConfig({ |
| 19 | test: { |
| 20 | projects: [ |
| 21 | { |
| 22 | resolve: { alias }, |
| 23 | test: { |
| 24 | name: "node", |
| 25 | globals: true, |
| 26 | environment: "node", |
| 27 | setupFiles: ["./src/i18n/test-locales.ts"], |
| 28 | include: ["src/**/*.test.ts"], |
| 29 | exclude: [...exclude, "src/components/layout/nav-items.test.ts"], |
| 30 | }, |
| 31 | }, |
| 32 | { |
| 33 | // `hot: false`: the plugin otherwise injects solid-refresh's virtual |
| 34 | // module, and vitest hands node the unresolvable `file:///@solid-refresh` |
| 35 | // specifier — every *.test.tsx file failed to load on that alone. There |
| 36 | // is no HMR in a test run for it to serve. |
| 37 | plugins: [solid({ hot: false })], |
| 38 | // "development"/"browser" so solid-js resolves to its client build once — |
| 39 | // a dual-loaded solid-js gives components a different reactive graph. |
| 40 | resolve: { alias, conditions: ["development", "browser"] }, |
| 41 | test: { |
| 42 | name: "dom", |
| 43 | globals: true, |
| 44 | environment: "jsdom", |
| 45 | environmentOptions: { |
| 46 | jsdom: { url: "http://localhost/" }, |
| 47 | }, |
| 48 | setupFiles: ["./src/i18n/test-locales.ts", "./src/test-setup.ts"], |
| 49 | include: ["src/**/*.test.tsx", "src/components/layout/nav-items.test.ts"], |
| 50 | exclude, |
| 51 | }, |
| 52 | }, |
| 53 | ], |
| 54 | }, |
| 55 | }); |