Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/web/modules/auth/hooks/use-sign-out.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment jsdom
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { FORMBRICKS_ENVIRONMENT_ID_LS, FORMBRICKS_WORKSPACE_ID_LS } from "@/lib/localStorage";
import { logSignOutAction } from "@/modules/auth/actions/sign-out";
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"@vitest/coverage-v8": "4.1.6",
"cross-env": "10.1.0",
"dotenv": "17.3.1",
"jsdom": "29.1.1",
"postcss": "8.5.14",
"resize-observer-polyfill": "1.5.1",
"tailwindcss-animate": "1.0.7",
Expand Down
29 changes: 27 additions & 2 deletions apps/web/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,38 @@ import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
environment: "node",
environmentMatchGlobs: [["**/*.test.tsx", "jsdom"]],
// Integration tests run only via `pnpm test:integration` (vitest.integration.config.mts) against a
// real Postgres + Redis; the unit config mocks the DB, so they must be excluded here (ENG-1054).
exclude: ["playwright/**", "node_modules/**", ".next/**", "**/*.integration.test.ts"],
setupFiles: ["./vitestSetup.ts"],
env: loadEnv("", process.cwd(), ""),
// Environment selection (ENG-1680): Vitest 4 removed `environmentMatchGlobs`, so environments
// are assigned via projects. *.test.ts run in node; *.test.tsx (component tests) run in jsdom
// automatically - no `@vitest-environment` pragma needed.
projects: [
{
extends: true,
test: {
name: "unit",
environment: "node",
exclude: [
"playwright/**",
"node_modules/**",
".next/**",
"**/*.integration.test.ts",
"**/*.test.tsx",
],
},
},
{
extends: true,
test: {
name: "components",
environment: "jsdom",
include: ["**/*.test.tsx"],
},
},
],
coverage: {
provider: "v8", // Use V8 as the coverage provider
reporter: ["text", "html", "lcov"], // Generate text summary and HTML reports
Expand Down
1 change: 0 additions & 1 deletion packages/surveys/src/components/general/survey.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment happy-dom
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/preact";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import type { TJsWorkspaceStateSurvey } from "@formbricks/types/js";
Expand Down
1 change: 0 additions & 1 deletion packages/surveys/src/lib/use-focus-trap.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment happy-dom
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/preact";
import { type ComponentChildren } from "preact";
import { afterEach, describe, expect, test, vi } from "vitest";
Expand Down
31 changes: 24 additions & 7 deletions packages/surveys/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,33 @@ const config = ({ mode }) => {
return defineConfig({
...sharedConfig,
test: {
name: "surveys",
environment: "node",
environmentMatchGlobs: [
["**/*.test.tsx", "jsdom"],
["**/lib/**/*.test.ts", "jsdom"],
],
setupFiles: ["./vitestSetup.ts"],
include: ["**/*.test.ts", "**/*.test.tsx"],
exclude: ["dist/**", "node_modules/**"],
env: env,
// Environment selection (ENG-1680): Vitest 4 removed `environmentMatchGlobs`, so environments
// are assigned via projects. *.test.tsx (component tests) run in happy-dom automatically;
// *.test.ts default to node — the few DOM-dependent .ts tests keep their per-file
// `@vitest-environment happy-dom` pragma.
projects: [
{
extends: true,
test: {
name: "surveys-unit",
environment: "node",
include: ["**/*.test.ts"],
exclude: ["dist/**", "node_modules/**"],
},
},
{
extends: true,
test: {
name: "surveys-components",
environment: "happy-dom",
include: ["**/*.test.tsx"],
exclude: ["dist/**", "node_modules/**"],
},
},
],
coverage: {
provider: "v8",
reporter: ["text", "html", "lcov"],
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vitest.workspace.ts

This file was deleted.

Loading