chore: upgrade vitest (#1091)

* chore: upgrade vitest

* chore: sync lock
This commit is contained in:
Matteo Pietro Dazzi
2026-05-20 12:14:13 +00:00
committed by GitHub
parent c88f6fb2c2
commit e58ea31d6d
14 changed files with 1817 additions and 323 deletions
+4 -4
View File
@@ -16,7 +16,7 @@ Replace the OpenCode provider's per-directory `/event` stream with OpenCode's `/
Each OpenCode test file was run independently with:
```bash
/opt/homebrew/bin/timeout 420s npx vitest run <file> --maxWorkers=1 --minWorkers=1
/opt/homebrew/bin/timeout 420s npx vitest run <file> --maxWorkers=1
```
## Baseline
@@ -44,6 +44,6 @@ One live reasoning-dedup matrix run returned no reasoning content; an immediate
- `npm run typecheck`
- `npm run lint`
- `git diff --check`
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.test.ts --maxWorkers=1 --minWorkers=1`
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.error-handling.real.e2e.test.ts --maxWorkers=1 --minWorkers=1`
- `npx vitest run packages/server/src/server/daemon-e2e/opencode-initial-prompt-wait.real.e2e.test.ts --maxWorkers=1 --minWorkers=1`
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.test.ts --maxWorkers=1`
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.error-handling.real.e2e.test.ts --maxWorkers=1`
- `npx vitest run packages/server/src/server/daemon-e2e/opencode-initial-prompt-wait.real.e2e.test.ts --maxWorkers=1`
+1759 -274
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -105,7 +105,8 @@
"@types/qrcode": "^1.5.6",
"@types/react": "~19.2.0",
"@types/ws": "^8.18.1",
"@vitest/browser": "^3.2.4",
"@vitest/browser": "^4.1.7",
"@vitest/browser-playwright": "^4.1.7",
"@xterm/headless": "^6.0.0",
"dotenv": "^17.2.3",
"eas-cli": "^16.24.1",
@@ -115,7 +116,7 @@
"material-icon-theme": "^5.32.0",
"playwright": "^1.56.1",
"typescript": "~5.9.2",
"vitest": "^3.2.4",
"vitest": "^4.1.6",
"wrangler": "^4.75.0",
"ws": "^8.20.0"
}
@@ -7,6 +7,7 @@ import {
type AssistantFileLinkContext,
type DirectorySuggestionEntry,
type DirectorySuggestionResult,
type GetDirectorySuggestions,
} from "./resolver";
const CONTEXT: AssistantFileLinkContext = {
@@ -20,7 +21,7 @@ function resolvedSuggestions(
}
function suggestionsFromMap(entriesByQuery: Record<string, DirectorySuggestionEntry[]>): {
getDirectorySuggestions: ReturnType<typeof vi.fn>;
getDirectorySuggestions: GetDirectorySuggestions;
searches: Array<{
query: string;
cwd: string;
@@ -34,7 +35,7 @@ function suggestionsFromMap(entriesByQuery: Record<string, DirectorySuggestionEn
matchMode: "suffix";
limit: number;
}> = [];
const getDirectorySuggestions = vi.fn(
const getDirectorySuggestions = vi.fn<GetDirectorySuggestions>(
async (input: {
query: string;
cwd: string;
@@ -192,7 +193,7 @@ describe("fetchDaemonResolution", () => {
});
it("throws a typed unresolved error when the daemon throws", async () => {
const getDirectorySuggestions = vi.fn(async () => {
const getDirectorySuggestions = vi.fn<GetDirectorySuggestions>(async () => {
throw new Error("daemon unavailable");
});
@@ -5,6 +5,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { act, renderHook, waitFor } from "@testing-library/react";
import React, { useCallback, useMemo, useState, type ReactNode } from "react";
import { describe, expect, it, vi } from "vitest";
import type { ToastApi } from "@/components/toast-host";
import type { InlinePathTarget } from "./parse";
import { AssistantFileLinkResolverProvider } from "./provider";
import type { DirectorySuggestionResult } from "./resolver";
@@ -63,15 +64,15 @@ function createQueryClient(): QueryClient {
});
}
function createWrapper(input: {
client: TestClient;
openedFiles: OpenedFile[];
toast?: {
show: ReturnType<typeof vi.fn>;
copied: ReturnType<typeof vi.fn>;
error: ReturnType<typeof vi.fn>;
function createToast(): ToastApi {
return {
show: vi.fn<ToastApi["show"]>(),
copied: vi.fn<ToastApi["copied"]>(),
error: vi.fn<ToastApi["error"]>(),
};
}) {
}
function createWrapper(input: { client: TestClient; openedFiles: OpenedFile[]; toast?: ToastApi }) {
const queryClient = createQueryClient();
return function Wrapper({ children }: { children: ReactNode }) {
const openWorkspaceFile = useCallback(
@@ -118,7 +119,7 @@ describe("useFileLink", () => {
serverId: "server-1",
workspaceRoot: "/Users/test/project",
onOpenWorkspaceFile: () => {},
toast: { show: vi.fn(), copied: vi.fn(), error: vi.fn() },
toast: createToast(),
},
children,
),
@@ -145,7 +146,7 @@ describe("useFileLink", () => {
.mockResolvedValueOnce(resolvedSuggestions([]))
.mockResolvedValueOnce(resolvedSuggestions([{ path: "docs/dumm.md", kind: "file" }]));
const openedFiles: OpenedFile[] = [];
const toast = { show: vi.fn(), copied: vi.fn(), error: vi.fn() };
const toast = createToast();
const { result } = renderHook(() => useFileLink(SOURCE), {
wrapper: createWrapper({
client: { getDirectorySuggestions },
@@ -2,6 +2,7 @@
import { act, renderHook, waitFor } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { ToastApi } from "@/components/toast-host";
import { useSessionStore } from "@/stores/session-store";
import { TIMELINE_FETCH_PAGE_SIZE } from "@/timeline/timeline-fetch-policy";
import { useLoadOlderAgentHistory } from "./use-load-older-agent-history";
@@ -9,7 +10,19 @@ import { useLoadOlderAgentHistory } from "./use-load-older-agent-history";
const serverId = "server-1";
const agentId = "agent-1";
function makeClient(fetchAgentTimeline = vi.fn().mockResolvedValue(undefined)) {
type FetchAgentTimeline = (agentId: string, request: unknown) => Promise<void>;
function createToast(): ToastApi {
return {
show: vi.fn<ToastApi["show"]>(),
copied: vi.fn<ToastApi["copied"]>(),
error: vi.fn<ToastApi["error"]>(),
};
}
function makeClient(
fetchAgentTimeline: FetchAgentTimeline = vi.fn<FetchAgentTimeline>().mockResolvedValue(undefined),
) {
return { fetchAgentTimeline };
}
@@ -17,7 +30,7 @@ function initialize(input?: {
cursor?: { epoch: string; startSeq: number; endSeq: number };
hasOlder?: boolean;
inFlight?: boolean;
fetchAgentTimeline?: ReturnType<typeof vi.fn>;
fetchAgentTimeline?: FetchAgentTimeline;
}) {
const client = makeClient(input?.fetchAgentTimeline);
useSessionStore.getState().initializeSession(serverId, client as never);
@@ -69,7 +82,7 @@ describe("useLoadOlderAgentHistory", () => {
});
it("dedupes concurrent older-page requests", () => {
const fetchAgentTimeline = vi.fn(
const fetchAgentTimeline = vi.fn<FetchAgentTimeline>(
() =>
new Promise<void>((resolve) => {
setTimeout(resolve, 20);
@@ -120,9 +133,9 @@ describe("useLoadOlderAgentHistory", () => {
const client = initialize({
cursor: { epoch: "epoch-1", startSeq: 10, endSeq: 20 },
hasOlder: true,
fetchAgentTimeline: vi.fn().mockRejectedValue(error),
fetchAgentTimeline: vi.fn<FetchAgentTimeline>().mockRejectedValue(error),
});
const toast = { show: vi.fn(), copied: vi.fn(), error: vi.fn() };
const toast = createToast();
const { result } = renderHook(() => useLoadOlderAgentHistory({ serverId, agentId, toast }));
act(() => {
+5 -3
View File
@@ -135,6 +135,8 @@ function queryRowIds(): string[] {
).map((node) => node.getAttribute("data-testid")?.replace("subagents-section-row-", "") ?? "");
}
type SubagentAction = (id: string) => void;
describe("SubagentsSection", () => {
let container: HTMLElement | null = null;
let root: Root | null = null;
@@ -169,9 +171,9 @@ describe("SubagentsSection", () => {
function render(
rows: SubagentRow[],
onOpenSubagent: ReturnType<typeof vi.fn> = vi.fn(),
onArchiveSubagent: ReturnType<typeof vi.fn> = vi.fn(),
): ReturnType<typeof vi.fn> {
onOpenSubagent: SubagentAction = vi.fn<SubagentAction>(),
onArchiveSubagent: SubagentAction = vi.fn<SubagentAction>(),
): SubagentAction {
act(() => {
root?.render(
<SubagentsSection
+3 -6
View File
@@ -1,4 +1,5 @@
import { defineConfig, configDefaults } from "vitest/config";
import { playwright } from "@vitest/browser-playwright";
import path from "path";
import fs from "fs";
@@ -33,7 +34,7 @@ export default defineConfig({
include: ["src/**/*.browser.{test,spec}.{ts,tsx}"],
browser: {
enabled: true,
provider: "playwright",
provider: playwright(),
headless: true,
connectTimeout: 180_000,
instances: [{ browser: "chromium" }],
@@ -49,11 +50,7 @@ export default defineConfig({
* keeps `process.send` intact so the app tests can boot before hitting the intentional failures.
*/
pool: "forks",
poolOptions: {
forks: {
maxForks: 2,
},
},
maxWorkers: 2,
server: {
deps: {
fallbackCJS: true,
+1 -1
View File
@@ -37,7 +37,7 @@
"@types/ws": "^8.5.8",
"tsx": "^4.6.0",
"typescript": "^5.2.2",
"vitest": "^3.2.4",
"vitest": "^4.1.6",
"zx": "^8.8.5"
}
}
+1 -1
View File
@@ -37,7 +37,7 @@
"electron-builder": "26.8.1",
"typescript": "5.9.3",
"unzip-crx-3": "^0.2.0",
"vitest": "^3.2.4",
"vitest": "^4.1.6",
"wait-on": "8.0.5"
}
}
+1 -1
View File
@@ -43,6 +43,6 @@
},
"devDependencies": {
"typescript": "^5.9.2",
"vitest": "^3.2.4"
"vitest": "^4.1.6"
}
}
+1 -1
View File
@@ -46,6 +46,6 @@
"@types/node": "^20.9.0",
"@types/ws": "^8.5.8",
"typescript": "^5.2.2",
"vitest": "^3.2.4"
"vitest": "^4.1.6"
}
}
+5 -5
View File
@@ -48,14 +48,14 @@
"speech:transcribe:local": "tsx scripts/transcribe-local-wav.ts",
"test": "npm run test:unit && npm run test:integration",
"test:unit": "vitest run --exclude \"**/*.e2e.test.ts\"",
"test:integration": "vitest run --maxWorkers=1 --minWorkers=1 src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts",
"test:integration": "vitest run --maxWorkers=1 src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts",
"test:integration:all": "npm run test:e2e",
"test:integration:real": "vitest run real.e2e.test.ts",
"test:integration:local": "vitest run local.e2e.test.ts",
"test:watch": "vitest",
"test:ui": "vitest --ui",
"test:e2e": "vitest run e2e.test.ts --maxWorkers=1 --minWorkers=1 --exclude \"**/*.real.e2e.test.ts\" --exclude \"**/*.local.e2e.test.ts\"",
"test:e2e:all": "vitest run e2e.test.ts --maxWorkers=1 --minWorkers=1",
"test:e2e": "vitest run e2e.test.ts --maxWorkers=1 --exclude \"**/*.real.e2e.test.ts\" --exclude \"**/*.local.e2e.test.ts\"",
"test:e2e:all": "vitest run e2e.test.ts --maxWorkers=1",
"test:e2e:real": "npm run test:integration:real",
"test:e2e:local": "npm run test:integration:local",
"test:e2e:ui": "vitest --ui e2e.test.ts"
@@ -103,11 +103,11 @@
"@types/qrcode": "^1.5.6",
"@types/uuid": "^9.0.7",
"@types/ws": "^8.5.8",
"@vitest/ui": "^3.2.4",
"@vitest/ui": "^4.1.6",
"cross-env": "^10.1.0",
"tsx": "^4.6.0",
"typescript": "^5.2.2",
"vitest": "^3.2.4"
"vitest": "^4.1.6"
},
"overrides": {
"lightningcss": "1.30.1"
+1 -7
View File
@@ -14,13 +14,7 @@ export default defineConfig({
environment: "node",
setupFiles: [path.resolve(__dirname, "./src/test-utils/vitest-setup.ts")],
pool: "forks",
poolOptions: {
forks: {
singleFork: true,
minForks: 1,
maxForks: 1,
},
},
fileParallelism: false,
exclude: ["**/node_modules/**", "**/dist/**", "**/.claude/**"],
},
});