@temporal-contract/testing / contract
contract
Type Aliases
ContractTestContext
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
| Property | Type | Description | Defined in |
|---|---|---|---|
client | ContractClient<TContract> | Contract-bound client — typedClient.for(contract). | contract.ts:83 |
typedClient | TypedClient | Connection-scoped root, for binding further contracts or reaching the raw escape hatch. | contract.ts:88 |
worker | TypedWorker | The 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
type CreateContractTestOptions<TContract> = object;Defined in: contract.ts:52
Options for createContractTest.
Type Parameters
| Type Parameter |
|---|
TContract extends ContractDefinition |
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
activities? | ActivitiesHandler<TContract> | Activities handler built with declareActivitiesHandler. Omit it for a workflow-only worker. | contract.ts:65 |
contract | TContract | The 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 |
workflowsPath | string | Path 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()
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
| Parameter | Type |
|---|---|
options | CreateContractTestOptions<TContract> |
Returns
TestAPI<{ client: ContractClient<TContract>; clientConnection: Connection; typedClient: TypedClient; worker: TypedWorker; workerConnection: NativeConnection; }>