perf(test): speed up suites and reduce fs churn

This commit is contained in:
Peter Steinberger
2026-02-15 19:18:49 +00:00
parent 8fdde0429e
commit 92f8c0fac3
32 changed files with 1793 additions and 1398 deletions

View File

@@ -1,7 +1,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import {
clearSessionStoreCacheForTest,
loadSessionStore,
@@ -10,12 +10,23 @@ import {
} from "./sessions.js";
describe("Session Store Cache", () => {
let fixtureRoot = "";
let caseId = 0;
let testDir: string;
let storePath: string;
beforeAll(() => {
fixtureRoot = fs.mkdtempSync(path.join(os.tmpdir(), "session-cache-test-"));
});
afterAll(() => {
if (fixtureRoot) {
fs.rmSync(fixtureRoot, { recursive: true, force: true });
}
});
beforeEach(() => {
// Create a temporary directory for test
testDir = path.join(os.tmpdir(), `session-cache-test-${Date.now()}`);
testDir = path.join(fixtureRoot, `case-${caseId++}`);
fs.mkdirSync(testDir, { recursive: true });
storePath = path.join(testDir, "sessions.json");
@@ -27,10 +38,6 @@ describe("Session Store Cache", () => {
});
afterEach(() => {
// Clean up test directory
if (fs.existsSync(testDir)) {
fs.rmSync(testDir, { recursive: true, force: true });
}
clearSessionStoreCacheForTest();
delete process.env.OPENCLAW_SESSION_CACHE_TTL_MS;
});