testing/rpc_round_trip.ts

Schema-driven round-trip validation for RPC endpoints.

For every RPC method, generates valid params and fires JSON-RPC requests (POST for all methods, GET for reads), validating that responses are well-formed JSON-RPC. Successful responses are validated against the method's declared output schema. DB-backed via create_test_app.

Declarations
#

2 declarations

view source

describe_rpc_round_trip_tests
#

testing/rpc_round_trip.ts view source

(options: RpcRoundTripTestOptions): void

Run schema-driven round-trip validation for RPC endpoints.

For each method: 1. Generate valid params from the action's input schema 2. Fire a POST request with JSON-RPC envelope 3. For side_effects: false methods, also fire a GET request 4. Validate response is well-formed JSON-RPC; successful responses are also validated against the method's declared output schema

Error responses (from missing DB state, etc.) are expected and validated as well-formed JSON-RPC errors. Successful responses are validated against action.spec.output.

options

returns

void

RpcRoundTripTestOptions
#

testing/rpc_round_trip.ts view source

RpcRoundTripTestOptions

session_options

Session config for cookie-based auth.

type SessionOptions<string>

create_route_specs

Route spec factory — same one used in production.

type (ctx: AppServerContext) => Array<RouteSpec>

rpc_endpoints

RPC endpoint specs — the source RpcAction arrays for params generation.

Accepts either an array (eager) or a factory (ctx: AppServerContext) => Array<RpcEndpointSpec> — the factory form is required when action handlers must close over the per-test ctx.app_settings / ctx.deps. The factory must return the same endpoint path and spec.method list regardless of ctx — it is invoked once at setup (via a stub ctx) to enumerate methods and again per-test by create_app_server for live dispatch.

app_options

Optional overrides for AppServerOptions.

db_factories

Database factories to run tests against. Default: pglite only.

type Array<DbFactory>

skip_methods

Methods to skip, by name (e.g., 'tx_plan').

type Array<string>

input_overrides

Override generated params for specific methods (method name → params).

type Map<string, Record<string, unknown>>

Depends on
#