evalite
Version:
Test your LLM-powered apps with a TypeScript-native, Vitest-based eval runner. No API key required.
36 lines • 1.17 kB
JavaScript
import { it } from "vitest";
import { SqliteStorage } from "./sqlite.js";
import { InMemoryStorage } from "./in-memory.js";
/**
* Registry of all storage to test. Add new storage here.
*/
const ADAPTERS_TO_TEST = [
{
name: "SqliteStorage",
factory: async () => SqliteStorage.create(":memory:"),
},
{
name: "InMemoryStorage",
factory: async () => InMemoryStorage.create(),
},
];
/**
* Test utility that runs the same test suite against all registered storage.
* Each test will be run with `it.each` for every storage in ADAPTERS_TO_TEST.
*
* @param name - Name of the test
* @param testFn - Async function that receives a factory to create fresh storage instances
*
* @example
* testStorage("creates run with correct runType", async (getStorage) => {
* await using storage = await getStorage();
* const run = await storage.runs.create({ runType: "full" });
* expect(run.runType).toBe("full");
* });
*/
export function testAllStorage(name, testFn) {
it.each(ADAPTERS_TO_TEST)(`$name - ${name}`, async ({ factory }) => {
await testFn(factory);
});
}
//# sourceMappingURL=test-utils.js.map