rivetkit
Version:
Lightweight libraries for building stateful actors on edge platforms
67 lines (64 loc) • 2.13 kB
TypeScript
import { T as Transport, E as Encoding, K as Registry, D as DriverConfig } from '../conn-DfPG71FA.js';
import 'hono/streaming';
import 'hono/ws';
import '../utils.js';
import '../utils-fwx3o3K9.js';
import 'hono';
import 'hono/utils/http-status';
import 'zod';
import 'pino';
import 'nanoevents';
import 'zod/v4';
interface SkipTests {
schedule?: boolean;
sleep?: boolean;
sse?: boolean;
inline?: boolean;
}
interface DriverTestConfig {
/** Deploys an registry and returns the connection endpoint. */
start(): Promise<DriverDeployOutput>;
/**
* If we're testing with an external system, we should use real timers
* instead of Vitest's mocked timers.
**/
useRealTimers?: boolean;
/** Cloudflare Workers has some bugs with cleanup. */
HACK_skipCleanupNet?: boolean;
skip?: SkipTests;
transport?: Transport;
encoding?: Encoding;
clientType: ClientType;
cleanup?: () => Promise<void>;
}
/**
* The type of client to run the test with.
*
* The logic for HTTP vs inline is very different, so this helps validate all behavior matches.
**/
type ClientType = "http" | "inline";
interface DriverDeployOutput {
endpoint: string;
namespace: string;
runnerName: string;
/** Cleans up the test. */
cleanup(): Promise<void>;
}
/** Runs all Vitest tests against the provided drivers. */
declare function runDriverTests(driverTestConfigPartial: Omit<DriverTestConfig, "clientType" | "transport" | "encoding">): void;
/**
* Helper function to adapt the drivers to the Node.js runtime for tests.
*
* This is helpful for drivers that run in-process as opposed to drivers that rely on external tools.
*/
declare function createTestRuntime(registryPath: string, driverFactory: (registry: Registry<any>) => Promise<{
rivetEngine?: {
endpoint: string;
namespace: string;
runnerName: string;
token: string;
};
driver: DriverConfig;
cleanup?: () => Promise<void>;
}>): Promise<DriverDeployOutput>;
export { type DriverDeployOutput, type DriverTestConfig, type SkipTests, createTestRuntime, runDriverTests };