pi-mono/packages/durable/test-workers/vitest.config.ts
Mario Zechner ea7c648430 feat(durable): workerd tests for Durable Object hosting
Runs the storage conformance suite, the schema migration, an alarm-woken sleep across an eviction, and a
turn recovered through the recovery alarm in workerd via @cloudflare/vitest-plugin (npm run test:workers).

fix(durable): decline background timers in Cloudflare Workers. With nodejs_compat, timers have an unref(),
so the idle-memory timers were armed and a pending one kept a Durable Object from hibernating or being evicted.
2026-10-17 23:02:48 +00:00

24 lines
937 B
TypeScript

import { fileURLToPath } from "node:url";
import { cloudflareTest } from "@cloudflare/vitest-plugin";
import { defineConfig } from "vitest/config";
const source = (path: string) => fileURLToPath(new URL(path, import.meta.url));
// Runs in workerd: the Durable Object storage, alarms, and eviction are Cloudflare's own.
export default defineConfig({
root: source("."),
plugins: [cloudflareTest({ wrangler: { configPath: source("./wrangler.jsonc") } })],
test: { include: ["*.test.ts"] },
resolve: {
conditions: ["source"],
alias: [
{ find: /^@earendil-works\/pi-durable$/, replacement: source("../src/index.ts") },
{ find: /^@earendil-works\/pi-durable\/testing$/, replacement: source("../src/testing/index.ts") },
{
find: /^@earendil-works\/pi-durable\/storage\/sqlite\/cloudflare$/,
replacement: source("../src/storage/sqlite/cloudflare.ts"),
},
],
},
ssr: { resolve: { conditions: ["source"] } },
});