test: dedupe and optimize test suites

This commit is contained in:
Peter Steinberger
2026-02-19 15:18:50 +00:00
parent b0e55283d5
commit a1cb700a05
80 changed files with 2627 additions and 2962 deletions

View File

@@ -1,5 +1,5 @@
import { ReadableStream } from "node:stream/web";
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import type { VoyageBatchOutputLine, VoyageBatchRequest } from "./batch-voyage.js";
import type { VoyageEmbeddingClient } from "./embeddings-voyage.js";
@@ -10,6 +10,12 @@ vi.mock("../infra/retry.js", () => ({
}));
describe("runVoyageEmbeddingBatches", () => {
let runVoyageEmbeddingBatches: typeof import("./batch-voyage.js").runVoyageEmbeddingBatches;
beforeAll(async () => {
({ runVoyageEmbeddingBatches } = await import("./batch-voyage.js"));
});
afterEach(() => {
vi.resetAllMocks();
vi.unstubAllGlobals();
@@ -84,8 +90,6 @@ describe("runVoyageEmbeddingBatches", () => {
body: stream,
});
const { runVoyageEmbeddingBatches } = await import("./batch-voyage.js");
const results = await runVoyageEmbeddingBatches({
client: mockClient,
agentId: "agent-1",
@@ -156,8 +160,6 @@ describe("runVoyageEmbeddingBatches", () => {
fetchMock.mockResolvedValueOnce({ ok: true, body: stream });
const { runVoyageEmbeddingBatches } = await import("./batch-voyage.js");
const results = await runVoyageEmbeddingBatches({
client: mockClient,
agentId: "a1",