Skip to content

@temporal-contract/testing


@temporal-contract/testing / contract

contract ​

Type Aliases ​

ContractTestContext ​

ts
type ContractTestContext<TContract> = object;

Defined in: contract.ts:81

Fixture context exposed by the it returned from createContractTest.

Type Parameters ​

Type Parameter
TContract extends ContractDefinition

Properties ​

PropertyTypeDescriptionDefined in
clientContractClient<TContract>Contract-bound client — typedClient.for(contract).contract.ts:83
typedClientTypedClientConnection-scoped root, for binding further contracts or reaching the raw escape hatch.contract.ts:88
workerTypedWorkerThe running worker for the contract's task queue — created and started before the test (auto), shut down after it. The underlying Temporal Worker stays reachable via worker.raw.contract.ts:94

CreateContractTestOptions ​

ts
type CreateContractTestOptions<TContract> = object;

Defined in: contract.ts:52

Options for createContractTest.

Type Parameters ​

Type Parameter
TContract extends ContractDefinition

Properties ​

PropertyTypeDescriptionDefined in
activities?ActivitiesHandler<TContract>Activities handler built with declareActivitiesHandler. Omit it for a workflow-only worker.contract.ts:65
contractTContractThe contract under test — its task queue names the worker's queue.contract.ts:54
workerOptions?Omit<CreateWorkerOptions<TContract>, "activities" | "connection" | "contract" | "workflowsPath">Extra options forwarded to TypedWorker.create (e.g. namespace, interceptors, tuning knobs). The namespace, when given, is also used by the client fixtures.contract.ts:71
workflowsPathstringPath to the workflows file registered on the worker — typically built with workflowsPathFromURL(import.meta.url, "./x.workflows.js") from @temporal-contract/worker/worker.contract.ts:60

Functions ​

createContractTest() ​

ts
function createContractTest<TContract>(options): TestAPI<{
  client: ContractClient<TContract>;
  clientConnection: Connection;
  typedClient: TypedClient;
  worker: TypedWorker;
  workerConnection: NativeConnection;
}>;

Defined in: contract.ts:108

Build a Vitest it whose fixtures run the given contract against the testcontainers-provided Temporal server: a worker on the contract's task queue (started before each test, shut down after), the connection-scoped TypedClient root, and the contract-bound ContractClient.

Requires the @temporal-contract/testing/global-setup global setup (or a module default-exporting createGlobalSetup(...)) to be registered on the test project. The underlying clientConnection/workerConnection fixtures from ./extension remain available on the context.

Type Parameters ​

Type Parameter
TContract extends ContractDefinition

Parameters ​

ParameterType
optionsCreateContractTestOptions<TContract>

Returns ​

TestAPI<{ client: ContractClient<TContract>; clientConnection: Connection; typedClient: TypedClient; worker: TypedWorker; workerConnection: NativeConnection; }>

Released under the MIT License.