Choosing the Right Vitest Environment: jsdom vs Node for Web App Unit Tests
Decide whether to run Vitest tests in jsdom or Node, compare trade‑offs, and see how to configure per‑file overrides for a mixed‑environment test suite.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Decide whether to run Vitest tests in jsdom or Node, compare trade‑offs, and see how to configure per‑file overrides for a mixed‑environment test suite.
Use ESLint’s <code>overrides</code> to let <code>console.log</code> in test files while keeping <code>no-console</code> for production code. A practical config, run‑time verification, and common pitfalls are covered.
Goal Determine whether Vitest creates a new environment instance for each test file when the same environment name (e.g., "node") is used, or if it reuses a single instance across files, potentially leaking global state. Context Vitest’s configuration allows setting the test environment per file or globally via the environment key. The documentation does not