Integration/E2E tests should be structured and isolated: use consistent fixture setup/teardown to avoid flakiness and leftover files, and organize higher-level tests using reusable helpers and known-good inputs/models.
Apply this standard:
Example (fixture + cleanup):
import { afterEach, describe, it, expect } from "vitest";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
describe("some integration", () => {
let tempDir: string;
beforeEach(() => {
tempDir = mkdtempSync(join(tmpdir(), "pi-test-"));
});
afterEach(() => {
rmSync(tempDir, { recursive: true, force: true });
});
it("does the thing", () => {
// use tempDir safely
expect(tempDir).toBeTruthy();
});
});
Example (provider-organized E2E/unit structure sketch):
describe("openrouter provider", () => {
const knownGoodModel = "<provider-specific model>";
// shared helper used by multiple subtests
const runProviderTest = (input: unknown) => {/* call provider with knownGoodModel */};
it("does X", async () => {
const result = await runProviderTest({/* ... */});
// assert
});
});