Socket
Book a DemoInstallSign in
Socket

@temporalio/testing

Package Overview
Dependencies
Maintainers
7
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/testing

Temporal.io SDK Testing sub-package

latest
Source
npmnpm
Version
1.13.0
Version published
Weekly downloads
289K
21.02%
Maintainers
7
Weekly downloads
 
Created

What is @temporalio/testing?

@temporalio/testing is a package designed to facilitate the testing of Temporal workflows and activities. It provides tools to create test environments, mock activities, and validate workflow executions, ensuring that your Temporal-based applications behave as expected.

What are @temporalio/testing's main functionalities?

Test Environment Setup

This feature allows you to set up a test environment for running Temporal workflows. The `TestWorkflowEnvironment.create()` method initializes the environment, making it possible to run and test workflows in isolation.

const { TestWorkflowEnvironment } = require('@temporalio/testing');

async function setupTestEnv() {
  const testEnv = await TestWorkflowEnvironment.create();
  return testEnv;
}

setupTestEnv().then(env => console.log('Test environment setup complete.')).catch(err => console.error(err));

Mock Activities

This feature allows you to mock activities within your workflows. By providing mock implementations of activities, you can test workflows without relying on the actual activity implementations, making tests faster and more reliable.

const { TestWorkflowEnvironment } = require('@temporalio/testing');
const { Worker } = require('@temporalio/worker');

async function mockActivities() {
  const testEnv = await TestWorkflowEnvironment.create();
  const worker = await Worker.create({
    activities: {
      myActivity: async () => 'mocked result'
    },
    taskQueue: 'test-task-queue'
  });
  await worker.run();
}

mockActivities().then(() => console.log('Activities mocked.')).catch(err => console.error(err));

Workflow Execution Validation

This feature allows you to validate the execution of workflows. By using the `WorkflowClient` to execute workflows within the test environment, you can ensure that workflows produce the expected results.

const { TestWorkflowEnvironment } = require('@temporalio/testing');
const { Worker, WorkflowClient } = require('@temporalio/client');

async function validateWorkflowExecution() {
  const testEnv = await TestWorkflowEnvironment.create();
  const client = new WorkflowClient();
  const result = await client.execute('myWorkflow', { taskQueue: 'test-task-queue' });
  console.log('Workflow result:', result);
}

validateWorkflowExecution().then(() => console.log('Workflow execution validated.')).catch(err => console.error(err));

Other packages similar to @temporalio/testing

Keywords

temporal

FAQs

Package last updated on 27 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts