Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
perf(test): run Vitest in node, and jsdom only where a DOM is needed
Etienne Lescotf172110f55aa
diff --git a/electron/ai-edition/document-service.test.ts b/electron/ai-edition/document-service.test.tsindex 995044f75..30f5fd718 100644--- a/electron/ai-edition/document-service.test.ts+++ b/electron/ai-edition/document-service.test.ts@@ -387,7 +387,10 @@ describe("DocumentService", () => {expect(onDisk.annotations).toHaveLength(120);});- it("survives many interleaved saves of one project", async () => {+ // 20 real temp-file+rename round trips, serialized through the save queue.+ // That is genuinely more than 5s of disk when the rest of the suite is+ // running in parallel, so it gets its own timeout rather than flaking.+ it("survives many interleaved saves of one project", { timeout: 20_000 }, async () => {const doc = await service.createProject("Storm");// Sizes deliberately alternate long/short: equal-length writes overwrite// each other cleanly and would prove nothing.diff --git a/src/components/ai-edition/CaptionsPane.gating.test.tsx b/src/components/ai-edition/CaptionsPane.gating.test.tsxindex b1e87c92b..cae76b59a 100644--- a/src/components/ai-edition/CaptionsPane.gating.test.tsx+++ b/src/components/ai-edition/CaptionsPane.gating.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// Captions are a view of the transcript, so the pane's "Transcribe video"// button is a retry, not a first step — the background pass has already tried.// On a media with no audio track that retry can only fail again, so the buttondiff --git a/src/components/ai-edition/ChatWelcome.test.tsx b/src/components/ai-edition/ChatWelcome.test.tsxindex 28ccb4248..8d835285e 100644--- a/src/components/ai-edition/ChatWelcome.test.tsx+++ b/src/components/ai-edition/ChatWelcome.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// ChatWelcome guards the "no provider connected" empty state: the copy reaches// the DOM, the CTA fires, and a non-English locale is really translated rather// than falling back to English. localeParity.test.ts covers key presence fordiff --git a/src/components/ai-edition/ColorField.test.tsx b/src/components/ai-edition/ColorField.test.tsxindex 84e6f771e..636167367 100644--- a/src/components/ai-edition/ColorField.test.tsx+++ b/src/components/ai-edition/ColorField.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { fireEvent, render, screen } from "@testing-library/react";import { beforeAll, describe, expect, it, vi } from "vitest";diff --git a/src/components/ai-edition/EditorEmptyState.test.tsx b/src/components/ai-edition/EditorEmptyState.test.tsxindex e6ae69246..acb513e4b 100644--- a/src/components/ai-edition/EditorEmptyState.test.tsx+++ b/src/components/ai-edition/EditorEmptyState.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import type { ReactElement } from "react";diff --git a/src/components/ai-edition/NewProjectModal.test.tsx b/src/components/ai-edition/NewProjectModal.test.tsxindex 614479dd6..03469939d 100644--- a/src/components/ai-edition/NewProjectModal.test.tsx+++ b/src/components/ai-edition/NewProjectModal.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { cleanup, fireEvent, render, screen } from "@testing-library/react";import type { ReactElement } from "react";diff --git a/src/components/ai-edition/Preview.test.tsx b/src/components/ai-edition/Preview.test.tsxindex d3498dfeb..294ad4c30 100644--- a/src/components/ai-edition/Preview.test.tsx+++ b/src/components/ai-edition/Preview.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";diff --git a/src/components/ai-edition/RightPanes.i18n.test.tsx b/src/components/ai-edition/RightPanes.i18n.test.tsxindex 94c2ebf6a..36cfd8c80 100644--- a/src/components/ai-edition/RightPanes.i18n.test.tsx+++ b/src/components/ai-edition/RightPanes.i18n.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// Guards the right-rail settings panes against untranslated strings creeping// back in: every pane used to hardcode its English labels (title, tabs, slider// labels, help popover), so switching the app locale left the whole inspectordiff --git a/src/components/ai-edition/TranscriptPane.gating.test.tsx b/src/components/ai-edition/TranscriptPane.gating.test.tsxindex 354bbbb3c..008c6161f 100644--- a/src/components/ai-edition/TranscriptPane.gating.test.tsx+++ b/src/components/ai-edition/TranscriptPane.gating.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// The transcript pane's empty state is what a user meets before any transcript// exists — and, since transcription now runs by itself in the background, it is// also where they wait for one. These assertions pin the three answers it hasdiff --git a/src/components/ai-edition/TranscriptPane.keyboardCut.test.tsx b/src/components/ai-edition/TranscriptPane.keyboardCut.test.tsxindex c55ae8233..600982fe0 100644--- a/src/components/ai-edition/TranscriptPane.keyboardCut.test.tsx+++ b/src/components/ai-edition/TranscriptPane.keyboardCut.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// Backspace/Delete in the transcript pane, with the caret sitting BETWEEN words at editor// level. That is where `restoreCaretBeforeWord` parks it after every cut, so it is the// state the user is in when they hold Backspace to keep trimming — and the state wherediff --git a/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsx b/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsxindex 9ce354646..f11151122 100644--- a/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsx+++ b/src/components/ai-edition/TranscriptPane.sharedMedia.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// The rendered half of the shared-media cue bug. `findCueWordId` returning the right// answer is not enough on its own: the cue id is compared against every rendered word,// so while `data-word-id` carried the bare `word.id`, the SAME transcript word projecteddiff --git a/src/components/ai-edition/TransportBar.test.tsx b/src/components/ai-edition/TransportBar.test.tsxindex 517f94d97..4d29545fc 100644--- a/src/components/ai-edition/TransportBar.test.tsx+++ b/src/components/ai-edition/TransportBar.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";diff --git a/src/components/ai-edition/VirtualPreview.playback.test.tsx b/src/components/ai-edition/VirtualPreview.playback.test.tsxindex 5dce37785..f0389fe2a 100644--- a/src/components/ai-edition/VirtualPreview.playback.test.tsx+++ b/src/components/ai-edition/VirtualPreview.playback.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { act, cleanup, fireEvent, render } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";diff --git a/src/components/ai-edition/WebcamOverlay.test.tsx b/src/components/ai-edition/WebcamOverlay.test.tsxindex 9c49ec6f5..bdd36a558 100644--- a/src/components/ai-edition/WebcamOverlay.test.tsx+++ b/src/components/ai-edition/WebcamOverlay.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { cleanup, render } from "@testing-library/react";import { afterEach, describe, expect, it } from "vitest";diff --git a/src/components/ai-edition/backgroundImageUpload.test.tsx b/src/components/ai-edition/backgroundImageUpload.test.tsxindex d4b7f4607..bf2d95694 100644--- a/src/components/ai-edition/backgroundImageUpload.test.tsx+++ b/src/components/ai-edition/backgroundImageUpload.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdom// Cases recovered from the deleted `video-editor/backgroundImageUpload.test.ts`, whose// module was dropped as dead code in the 2026-07-26 reorg — correctly, since only its own// test imported it, but the empty-MIME fallback it encoded had never been wired into thediff --git a/src/components/ai-edition/v4/EditorTopBar.test.tsx b/src/components/ai-edition/v4/EditorTopBar.test.tsxindex 0dade6d48..364674659 100644--- a/src/components/ai-edition/v4/EditorTopBar.test.tsx+++ b/src/components/ai-edition/v4/EditorTopBar.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { fireEvent, render, screen } from "@testing-library/react";import { describe, expect, it, vi } from "vitest";diff --git a/src/components/ai-edition/v4/SpeedControl.test.tsx b/src/components/ai-edition/v4/SpeedControl.test.tsxindex c510227d7..50a9673ab 100644--- a/src/components/ai-edition/v4/SpeedControl.test.tsx+++ b/src/components/ai-edition/v4/SpeedControl.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { fireEvent, render, screen } from "@testing-library/react";import { beforeEach, describe, expect, it, vi } from "vitest";diff --git a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsxindex 490f4e0f4..280853bef 100644--- a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx+++ b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { fireEvent, render, screen } from "@testing-library/react";import { beforeAll, describe, expect, it, vi } from "vitest";diff --git a/src/components/launch/LaunchWindow.test.tsx b/src/components/launch/LaunchWindow.test.tsxindex 12d177c14..76b6a6fe9 100644--- a/src/components/launch/LaunchWindow.test.tsx+++ b/src/components/launch/LaunchWindow.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";diff --git a/src/components/launch/NotesToolbar.test.tsx b/src/components/launch/NotesToolbar.test.tsxindex 766e9c680..21a813eb3 100644--- a/src/components/launch/NotesToolbar.test.tsx+++ b/src/components/launch/NotesToolbar.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { render, screen, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";diff --git a/src/components/launch/NotesWindow.editable.test.tsx b/src/components/launch/NotesWindow.editable.test.tsxindex c13000cb0..8f4dc8528 100644--- a/src/components/launch/NotesWindow.editable.test.tsx+++ b/src/components/launch/NotesWindow.editable.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { render, screen } from "@testing-library/react";import userEvent from "@testing-library/user-event";diff --git a/src/components/launch/NotesWindow.test.tsx b/src/components/launch/NotesWindow.test.tsxindex d3f212078..4c74d186e 100644--- a/src/components/launch/NotesWindow.test.tsx+++ b/src/components/launch/NotesWindow.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { readFileSync } from "node:fs";import { resolve } from "node:path";diff --git a/src/components/launch/SourceSelector.test.tsx b/src/components/launch/SourceSelector.test.tsxindex 82172e1ce..7868d85da 100644--- a/src/components/launch/SourceSelector.test.tsx+++ b/src/components/launch/SourceSelector.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { fireEvent, render, screen, waitFor } from "@testing-library/react";import { beforeEach, describe, expect, it, vi } from "vitest";diff --git a/src/components/ui/gradient-editor.test.tsx b/src/components/ui/gradient-editor.test.tsxindex 0d54a26ea..81be1c3eb 100644--- a/src/components/ui/gradient-editor.test.tsx+++ b/src/components/ui/gradient-editor.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport "@testing-library/jest-dom";import { fireEvent, render, screen, waitFor } from "@testing-library/react";import { describe, expect, it, vi } from "vitest";diff --git a/src/hooks/recorderHandle.test.ts b/src/hooks/recorderHandle.test.tsindex 3f16437e3..91d7154b9 100644--- a/src/hooks/recorderHandle.test.ts+++ b/src/hooks/recorderHandle.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { createRecorderHandle } from "./recorderHandle";diff --git a/src/hooks/useAudioPeaks.test.ts b/src/hooks/useAudioPeaks.test.tsindex 77a850b78..0783cd2d9 100644--- a/src/hooks/useAudioPeaks.test.ts+++ b/src/hooks/useAudioPeaks.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdom// Two properties that decide whether a long recording's waveform appears// quickly or not at all: which pipeline a file is routed to, and how many times// it is decoded.diff --git a/src/hooks/useCameraDevices.test.ts b/src/hooks/useCameraDevices.test.tsindex e6ec8a9ed..2bef6f046 100644--- a/src/hooks/useCameraDevices.test.ts+++ b/src/hooks/useCameraDevices.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { act, renderHook, waitFor } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { useCameraDevices } from "./useCameraDevices";diff --git a/src/hooks/useScreenRecorder.nativeStopFailure.test.tsx b/src/hooks/useScreenRecorder.nativeStopFailure.test.tsxindex 52c786be4..928ac5886 100644--- a/src/hooks/useScreenRecorder.nativeStopFailure.test.tsx+++ b/src/hooks/useScreenRecorder.nativeStopFailure.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { act, renderHook } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";diff --git a/src/lib/ai-edition/store/projectStore.test.ts b/src/lib/ai-edition/store/projectStore.test.tsindex 278f8096d..5483f2b88 100644--- a/src/lib/ai-edition/store/projectStore.test.ts+++ b/src/lib/ai-edition/store/projectStore.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { useProjectStore } from "./projectStore";diff --git a/src/lib/ai-edition/store/transcriptionStore.test.ts b/src/lib/ai-edition/store/transcriptionStore.test.tsindex d8208ddef..03276bd25 100644--- a/src/lib/ai-edition/store/transcriptionStore.test.ts+++ b/src/lib/ai-edition/store/transcriptionStore.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { AxcutDocument, AxcutTranscript } from "../schema";import { useProjectStore } from "./projectStore";diff --git a/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts b/src/lib/ai-edition/store/useSequentialTimelineOps.test.tsindex 6ad4461cf..f86088bcf 100644--- a/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts+++ b/src/lib/ai-edition/store/useSequentialTimelineOps.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdom// ponytail: tests for the queued timeline-op hook. The hook used to live// inline in NewEditorShell.tsx (saveQueueRef + handleAddTrimRange /// handleRemoveTrimRange) and was untested; the bug it fixed (synchronousdiff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.tsindex ca1edf898..7f4541768 100644--- a/src/lib/ai-edition/store/useTimeline.test.ts+++ b/src/lib/ai-edition/store/useTimeline.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { act, renderHook, waitFor } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { I18nProvider } from "@/contexts/I18nContext";diff --git a/src/lib/ai-edition/timeline/duration.test.ts b/src/lib/ai-edition/timeline/duration.test.tsindex ba1dc3d11..528c3b910 100644--- a/src/lib/ai-edition/timeline/duration.test.ts+++ b/src/lib/ai-edition/timeline/duration.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { probeVideoDuration } from "./duration";diff --git a/src/lib/ai-edition/timeline/pointer-drag.test.tsx b/src/lib/ai-edition/timeline/pointer-drag.test.tsxindex 8ed7f5067..05a4730da 100644--- a/src/lib/ai-edition/timeline/pointer-drag.test.tsx+++ b/src/lib/ai-edition/timeline/pointer-drag.test.tsx@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { fireEvent, render } from "@testing-library/react";import { beforeEach, describe, expect, it, vi } from "vitest";import { startGlobalPointerDrag } from "./pointer-drag";diff --git a/src/lib/captioning/transcribe.test.ts b/src/lib/captioning/transcribe.test.tsindex 82e630b9a..505fc59b0 100644--- a/src/lib/captioning/transcribe.test.ts+++ b/src/lib/captioning/transcribe.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { afterEach, beforeEach, describe, expect, it, type Mock, vi } from "vitest";import { transcribeMono16kToSegments } from "./transcribe";diff --git a/src/native/hooks/useCompositorBackend.test.ts b/src/native/hooks/useCompositorBackend.test.tsindex e85410872..bb743a76a 100644--- a/src/native/hooks/useCompositorBackend.test.ts+++ b/src/native/hooks/useCompositorBackend.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdom/*** The CPU-backend notice must fire on a degraded GPU and stay silent everywhere else.*diff --git a/src/native/hooks/useNativeCompositorView.test.ts b/src/native/hooks/useNativeCompositorView.test.tsindex 8ef722c50..f3bf74ad0 100644--- a/src/native/hooks/useNativeCompositorView.test.ts+++ b/src/native/hooks/useNativeCompositorView.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdom/*** The fatal-error channel (PR #162).*diff --git a/src/utils/platformUtils.test.ts b/src/utils/platformUtils.test.tsindex bdc7772e0..41c11b8f6 100644--- a/src/utils/platformUtils.test.ts+++ b/src/utils/platformUtils.test.ts@@ -1,3 +1,4 @@+// @vitest-environment jsdomimport { afterEach, describe, expect, it } from "vitest";import { getPlatform, isMac } from "./platformUtils";diff --git a/vitest.config.ts b/vitest.config.tsindex e6b1497f9..d775a6e3f 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -4,9 +4,37 @@ import { defineConfig } from "vitest/config";export default defineConfig({test: {globals: true,- environment: "jsdom",+ // `node`, not `jsdom`. Building a jsdom for every test file was the single+ // most expensive thing this suite did — 719s of cumulative environment setup+ // against 89s of actual test time — and only 37 of the 140 files need a DOM+ // at all. Those 37 opt back in with a `// @vitest-environment jsdom` docblock+ // on line 1, which is also the fix when a new test dies on `document is not+ // defined`. (`electron/media/audioPeaks.test.ts` already used the same+ // docblock the other way round, to escape the global jsdom; that one is now+ // redundant but harmless.)+ environment: "node",include: ["{src,electron,.github}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],- exclude: ["src/**/*.browser.test.{ts,tsx}"],+ // Vitest's 5s default is too tight here and produces red runs that mean nothing.+ // Measured: with the machine loaded, 11 tests fail and 9 of them are purely+ // "Test timed out in 5000ms" — ordinary component tests that pass in 200ms on an+ // idle box. A single jsdom file needs ~9.5s just to boot React, so 5s of budget+ // is not a signal about the test. Raising this costs nothing on a passing run:+ // the timeout only ever fires on a test that was going to fail anyway.+ testTimeout: 15_000,+ // Everything else that looks like a speedup here was measured and is NOT one.+ // Full suite, same machine, back to back: 175s with jsdom everywhere, 81s with+ // the split above.+ // * `--no-isolate` ~20% faster, but it fails tests. Sharing one module+ // registry per worker breaks `vi.mock`, and 29 test+ // files rely on it (`@/native/client` alone is mocked+ // in 10 of them, differently each time). Not worth+ // making the suite's main mocking tool unsound.+ // * `deps.optimizer.web` slower, not faster.+ // * `--pool=threads` >5min, killed. jsdom in worker threads is pathological.+ // * `--maxWorkers=16` inside the run-to-run noise on an 8-core box, and a+ // number that would be wrong on any other machine.+ // What is left is import cost: a jsdom file is ~9.5s alone, of which ~6.7s is+ // pulling in React + testing-library and ~1.9s is the DOM itself.},resolve: {alias: {