@btravstack/temporal-testing
v0.62.0
Published
A Temporal server for the specs of @btravstack/temporal-worker and @btravstack/temporal-client consumers: one development server per Docker host, shared across processes, and a namespace per spec file
Maintainers
Readme
@btravstack/temporal-testing
A Temporal server for the specs of @btravstack/temporal-worker and
@btravstack/temporal-client consumers. temporalServer is a Vitest
globalSetup (the package's default export) that starts the Temporal CLI's
development server, temporalio/temporal running server start-dev in memory,
in one container through testcontainers. By default every run on the Docker
host shares that container, concurrent processes included.
temporalEnvironment(prefix) is a file-scoped fixture that registers a
namespace of the spec file's own and answers
{ TEMPORAL_ADDRESS, TEMPORAL_NAMESPACE }, the variables the starters read.
temporalNamespace(address, prefix) is the same registration without a test
context, for a globalSetup that registers one namespace for the run and
starts workers shared across spec files.
pnpm add -D @btravstack/temporal-testing @btravstack/testing vitest testcontainers @temporalio/client @temporalio/common// vitest.config.ts
export default defineConfig({
test: { globalSetup: ["@btravstack/temporal-testing"] },
});// test-fixtures.ts
export const it = test.extend<{ temporal: TemporalEnvironment; boot: Boot }>({
temporal: temporalEnvironment("orders"),
boot: bootFixture(),
});The suite needs a Docker daemon. temporalServer({ reuse: false }) owns a
server for the run instead, and stops it at the run's end.
