perf(test): run dashboard src tests in node env, app tests in jsdom
The dashboard backend (Express routes, services) lives under src/ and is pure Node logic, but every test was paying for jsdom env init plus full CSS-import processing. Split via environmentMatchGlobs so app/** keeps jsdom (React UI) and src/** runs in node by default. Two src tests opt back into jsdom: - status-bar.test.ts uses window.matchMedia. - proxy-routes.test.ts asserts on DOMException constructor.name, which jsdom reports as "AbortError" but node reports as "DOMException". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
// @vitest-environment jsdom
|
||||
// Uses DOMException("Aborted", "AbortError") whose constructor.name behaves
|
||||
// differently in node (resolves to "DOMException") vs jsdom ("AbortError"),
|
||||
// which the proxy error classifier asserts on.
|
||||
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { EventEmitter } from "node:events";
|
||||
import { request, get } from "../test-request.js";
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { StatusBarManager } from "../plugins/status-bar.js";
|
||||
|
||||
|
||||
@@ -16,7 +16,14 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
test: {
|
||||
environment: "jsdom",
|
||||
// `app/**` is React UI — needs jsdom + CSS. `src/**` is the Express
|
||||
// backend, mostly Node-only logic; running it in node env trims jsdom
|
||||
// env+CSS-include cost. The handful of src tests that genuinely need DOM
|
||||
// opt-in via `// @vitest-environment jsdom`.
|
||||
environment: "node",
|
||||
environmentMatchGlobs: [
|
||||
["app/**", "jsdom"],
|
||||
],
|
||||
// Process CSS imports so jsdom-based tests that assert on getComputedStyle
|
||||
// see the actual rules from co-located component CSS files.
|
||||
css: { include: [/.+/] },
|
||||
|
||||
Reference in New Issue
Block a user