Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@temporal-contract/testing

Testing utilities for temporal-contract integration tests

npm version

Installation

pnpm add -D @temporal-contract/testing

Quick Example

Global Setup

Configure Vitest to start a Temporal server before all tests:

// vitest.config.ts
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    globalSetup: "@temporal-contract/testing/global-setup",
    testTimeout: 60000,
  },
});

Test Extension

Use the it extension for automatic connection management:

// my-workflow.spec.ts
import { it } from "@temporal-contract/testing/extension";
import { expect } from "vitest";

it("should execute workflow", async ({ clientConnection, workerConnection }) => {
  // clientConnection: Connection from @temporalio/client (auto-connected, auto-closed)
  // workerConnection: NativeConnection from @temporalio/worker (auto-connected)

  const client = new Client({ connection: clientConnection });
  // ... use client and workerConnection in your test
});

Documentation

📖 Read the full documentation →

License

MIT