From a04e97a7536387d6962ff491af421d607f16a8d9 Mon Sep 17 00:00:00 2001 From: kumarabhirup Date: Mon, 2 Mar 2026 18:32:38 -0800 Subject: [PATCH] chore(web): configure vitest with jsdom env, JSX, and setup file --- apps/web/vitest.config.ts | 17 ++++++++++++++++- apps/web/vitest.setup.ts | 7 +++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 apps/web/vitest.setup.ts diff --git a/apps/web/vitest.config.ts b/apps/web/vitest.config.ts index 93fe3238847..a5fa034aa7f 100644 --- a/apps/web/vitest.config.ts +++ b/apps/web/vitest.config.ts @@ -2,13 +2,28 @@ import { defineConfig } from "vitest/config"; import path from "node:path"; export default defineConfig({ + esbuild: { + jsx: "automatic", + jsxImportSource: "react", + }, resolve: { alias: { "@": path.resolve(__dirname), }, }, test: { - include: ["lib/**/*.test.ts", "app/**/*.test.ts"], + environment: "node", + environmentMatchGlobs: [ + ["app/components/**/*.test.tsx", "jsdom"], + ["app/workspace/**/*.test.tsx", "jsdom"], + ], + setupFiles: ["./vitest.setup.ts"], + include: [ + "lib/**/*.test.ts", + "lib/**/*.test.tsx", + "app/**/*.test.ts", + "app/**/*.test.tsx", + ], testTimeout: 30_000, }, }); diff --git a/apps/web/vitest.setup.ts b/apps/web/vitest.setup.ts new file mode 100644 index 00000000000..2ba240b8d68 --- /dev/null +++ b/apps/web/vitest.setup.ts @@ -0,0 +1,7 @@ +import "@testing-library/jest-dom/vitest"; +import { afterEach } from "vitest"; +import { cleanup } from "@testing-library/react"; + +afterEach(() => { + cleanup(); +});