Disposable helper that captures live decoded contract events in integration tests.
-
all(): ReadonlyArray<TrellisTestCapturedEvent<TContract, TSelectedEvent>>
Returns captured events, optionally filtered by event name.
-
clear(): void
Removes all events captured so far without stopping live listeners.
- listenerSignal(): AbortSignal
- record(event: TrellisTestCapturedEvent<TContract, TSelectedEvent>): void
-
stop(): Promise<void>
Stops live listeners and closes the synthetic capture client connection once.
-
waitFor<E extends TSelectedEvent>(): Promise<TrellisTestCapturedEvent<TContract, E>>name: E,predicate?: TrellisTestCapturedEventPredicate<TContract, E>,opts?: WaitForOptions
Waits for the first captured event with the requested name and optional predicate.
Runs an isolated Trellis control plane and NATS server for integration tests.
-
captureEvents<>(args: TrellisTestEventCaptureOptions<TContract, TEvents>): Promise<TrellisTestEventCapture<TContract, TEvents[number]>>TContract extends TrellisTestEventSourceContract,TEvents extends readonly EventName<TContract>[]
Captures live decoded contract events through a synthetic app participant.
-
clientAuth(key: TrellisTestClientKey): TrellisTestClientAuth
Returns auth options and admin-backed auth continuation for a registered app/client participant. Spread the result into
TrellisClient.connect(...). -
connectClient<TContract extends TrellisTestClientContract<TrellisAPI>>(args: ClientOpts): Promise<TrellisTestConnectedClient<TContract>>
& { name: string; contract: TContract; sessionKeySeed?: string; }Connects an app/client participant through the public generated client surface.
- contracts: { approve(args: { deployment?: string; contract: RuntimeContract; allowPlanClassifications?: readonly TrellisTestAuthorityPlanClassification[]; }): Promise<TrellisTestContractApproval>; }
- deployments: { create(args: { id?: string; mutableDev?: boolean; }): Promise<void>; reconcile(deployment: string): Promise<void>; waitReady(deployment: string): Promise<void>; }
-
drain(): Promise<void>
Drains the underlying NATS connection.
-
flush(): Promise<void>
Flushes the underlying NATS connection.
- natsUrl: string
-
registerClient(args: { name: string; contract: TrellisTestClientContract; sessionKeySeed?: string; }): Promise<TrellisTestClientKey>
Creates app/client session-key material for public
TrellisClient.connectcalls. -
registerService(args: { name: string; contract: RuntimeContract; deployment?: string; sessionKeySeed?: string; }): Promise<TrellisTestServiceKey>
Registers a service contract and creates a service instance key.
- services: { createInstance(args: { deployment?: string; name: string; contract: RuntimeContract; sessionKeySeed?: string; }): Promise<TrellisTestServiceKey>; }
-
sqliteMemoryUrl(): string
Returns the SQLite in-memory URL used by service-owned tests.
-
start(options: TrellisTestRuntimeStartOptions): Promise<TrellisTestRuntime>
Starts an isolated Trellis test runtime.
-
stop(): Promise<void>
Stops clients, control plane, NATS, and the temp directory.
-
tempSqlitePath(name?: string): Promise<string>
Returns a service-owned SQLite path under this runtime workdir.
- trellisUrl: string
-
waitFor<T>(): Promise<T>fn: () =>T
| null
| undefined
| false
| Promise<T | null | undefined | false>,opts?: WaitForOptionsPolls until
fnreturns a truthy value. - workdir: string
Validates standard Trellis captured-event context metadata and returns the event.
Waits for a captured event and fails with captured-event context when it is absent.
| { readonly id?: string; wait(): TrellisTestTerminalWaitResult<TTerminal>; },
Asserts that a job reference or terminal job completed successfully.
Asserts that no matching event has been captured so far.
| TrellisTestAssertNoEventDuringOptions
| undefined,
Asserts that no matching event is captured during an explicit observation window.
| TrellisTestWaitableOperation<TProgress, TOutput>,
& { state: "completed"; }
Asserts that an operation reference or terminal operation completed successfully.
Asserts that a Trellis RPC-style result is Err and returns the error.
Polls a Trellis RPC-style call until it returns Ok and optional expected output matches.
Asserts that a Trellis RPC-style result is Ok and returns the Ok value.
Returns the SQLite in-memory URL used by service-owned tests.
Returns a fresh path suitable for a service-owned SQLite database.
| null
| undefined
| false
| Promise<T | null | undefined | false>,
Polls until fn returns a truthy value, preserving the last thrown error on timeout.
Options for assertEventsCaptured.
Minimal captured-event shape accepted by the generic event assertion helpers.
-
context: unknown
Trellis listener metadata for the captured event.
-
event: TEventName
Contract event name captured by the test listener.
-
payload: TPayload
Decoded event payload.
-
receivedAt: unknown
Wall-clock time when the test capture observed the event.
Structural event capture accepted by Trellis test event assertion helpers.
-
all(): ReadonlyArray<TEvent>
Returns events captured so far in capture order.
Predicate used by event assertion helpers to select a captured event.
Options for assertNoEventDuring.
-
durationMs: number
Duration to observe for newly captured events.
-
intervalMs: number
Poll interval while observing. Defaults to 10ms.
Options for assertRpcEventuallyOk.
A decoded contract event observed by a TrellisTestEventCapture.
Transport-neutral listener metadata captured with a test event.
-
id: string
Stable event id from the Trellis event header.
-
mode: "ephemeral"
Runtime listener mode that delivered the event.
-
time: Date
Event creation time from the Trellis event header.
Expected captured event context fields for assertCapturedEventContext.
-
id: string
Expected Trellis event id.
-
mode: "ephemeral"
Expected listener mode. Defaults to
ephemeral. -
receivedAt: Date
Expected capture receipt time.
-
time: Date
Expected Trellis event creation time.
Predicate used by TrellisTestEventCapture.waitFor.
Authentication options for connecting a test app/client participant.
Contract value accepted by app/client helpers.
Session-key material returned for a registered app/client participant.
& { API: { trellis: ApiForTestClientContract<TContract>; }; }
Connected app/client type returned by TrellisTestRuntime.connectClient.
Contract value accepted by the Trellis test runtime.
Result returned when a contract authority plan is approved by the test runtime.
Recursive subset expectation used by Trellis test assertion helpers.
& { readonly name: string; }
Error constructor or class object accepted by assertRpcErr.
Captured-event variant selected by event name when the event type is a union.
& { name: string; contract: TContract; events: TEvents; }
Options for starting a live decoded contract event capture.
Event expectation accepted by assertEventsCaptured.
Event expectation object accepted by assertEventsCaptured.
Contract value accepted by TrellisTestRuntime.captureEvents.
Minimal terminal job snapshot accepted by assertJobCompleted.
-
id: string
Trellis job id, when available from the source snapshot.
-
result: TResult
Job result payload, present for completed jobs that produce a result.
-
state: string
Terminal job state.
Generated-style wait result exposing an orThrow() terminal unwrap.
-
orThrow(): MaybePromise<TTerminal>
Returns the terminal snapshot or throws the underlying failure.
Options for starting an isolated Trellis test runtime.
Session-key material returned for a registered service.
| TrellisTestOrThrowWaitResult<TTerminal>
| Promise<TrellisTestOrThrowWaitResult<TTerminal> | TTerminal>
| TTerminal
Wait result shape accepted by terminal job and operation assertions.
Structural Trellis job reference accepted by assertJobCompleted.
-
id: string
Trellis job id, when available from the source reference.
-
wait(): TrellisTestTerminalWaitResult<TrellisTestJobTerminal<TResult>>
Waits for the job to reach a terminal state.
Structural Trellis operation reference accepted by assertOperationCompleted.
-
wait(): TrellisTestTerminalWaitResult<TerminalOperation<TProgress, TOutput>>
Waits for the operation to reach a terminal state.
| null
| undefined
| false
| Promise<T | null | undefined | false>,
Wait polling function accepted by eventual Trellis test assertion helpers.
| { readonly waitFor: TrellisTestWaitForFunction; }
Runtime-like object accepted by eventual Trellis test assertion helpers.
Polling options for waitFor and runtime readiness helpers.
Usage
import * as mod from "trellis-test/index.ts";