@camunda/task-testing

中文文档
7.1.0发布于 2026/11/07MITTypeScriptCommonJS近 30 天下载 1.4万

CI

原始使用文档
文档目录5 节
  1. Usage
  2. Props
  3. Development
  4. Build
  5. License

@camunda/task-testing

CI

Validate a single building block of your BPMN diagram by executing it against a connected cluster.

Usage

import TaskTesting from '@camunda/task-testing';

function App() {
  ...

  <TaskTesting
    { ...props }
  >
    <TaskTesting.Tab label="My dynamic tab" render={ ({ output }) => <div>...</div> } />
    <TaskTesting.Tab label="My static tab">My static content</TaskTesting.Tab>
    <TaskTesting.Link href="https://example.com" render={ ({ output }) => <div>...</div> } />
    <TaskTesting.Link href="https://example.com">My static link</TaskTesting.Link>
  </TaskTesting>
}

Props

PropTypeRequiredDescription
injectorObjectyesThe didi injector from the bpmn-js modeler
apiTaskExecutionApiyesAPI object with methods for deploying, starting instances, and polling
hasErrorbooleannoWhether an error is present
configConfignoInput/output configuration for elements
onConfigChanged(config: Config) => voidnoCalled when the configuration changes
errorBannerTitlestringnoTitle for the error banner (default: 'Error')
errorBannerDescriptionstringyesDescription for the error banner
errorBannerActionLabelstringyesLabel of the error banner button, which calls onConfigure
configureTooltipstringnoTooltip for the configure button (default: 'Configure')
onConfigureFunctionnoCalled when the user clicks the configure button
onTestTask() => boolean | Promise<boolean>noCalled when the user clicks Execute. Return true to proceed, false to abort
operateBaseUrlstringnoBase URL for Operate links
tasklistBaseUrlstringnoBase URL for Tasklist links
documentationUrlstringnoURL for the documentation link
onTaskExecutionStarted(element) => voidnoCalled when task execution starts
onTaskExecutionFinished(element, result) => voidnoCalled when task execution ends

TaskExecutionApi

The api prop must implement the following methods. Each method should return a { success: true, response } or { success: false, error } object.

MethodDescription
deploy()Deploy the process definition
startInstance(processDefinitionKey, elementId, variables)Start a process instance
getProcessInstance(processInstanceKey)Search for a process instance
getProcessInstanceElementInstances(processInstanceKey)Search element instances
getProcessInstanceIncident(processInstanceKey)Search incidents
getProcessInstanceJobs(processInstanceKey)Search jobs
getProcessInstanceMessageSubscriptions(processInstanceKey)Search message subscriptions
getProcessInstanceUserTasks(processInstanceKey)Search user tasks
getProcessInstanceVariables(processInstanceKey)Search variables

onTaskExecutionFinished result

The result parameter is a discriminated union:

  • success: true — Task completed successfully. Contains lastPolledResult and processInstanceKey.
  • success: false — Task did not complete successfully. Contains reason:
    • 'incident' — An incident occurred (includes incident details)
    • 'terminated' — Process instance was terminated
    • 'user.cancel' — User clicked cancel
    • 'user.selectionChanged' — User selected a different element
    • 'error' — Deployment or start failed (includes error with message)

Plugins

Custom tabs and links can be added as children:

  • <TaskTesting.Tab> — Adds a collapsible strip to the run card, below the built-in variables and timeline strips

    • label (string, required) — Strip label
    • render (function) — Render function receiving { output }, for dynamic content
    • children (ReactNode) — Static content (alternative to render)
    • priority (number, default 1000) — Higher priority strips appear first
    • fullBleed (boolean, default false) — Render the content edge to edge in a fixed-height, scroll-isolated body, for foreign HTML
    • onOpenExternal (function) — Adds a button to the strip header that calls it with { element, output, isTaskExecuting, executionLog }, e.g. to open the content in its own window
  • <TaskTesting.Link> — Adds a link to the output header

    • href (string, required) — Link URL
    • target (string) — Link target (e.g. '_blank')
    • render (function) — Render function receiving { output }, for dynamic content
    • children (ReactNode) — Static content (alternative to render)
    • priority (number, default 1000) — Higher priority links appear first

See demo

Development

Install the dependencies and spin up a local server at http://localhost:3000:

npm install

npm start

It requires a Camunda 8 instance to run.

We recommend using Camunda 8 Run for development.

Without further setup, the demo connects to a local Camunda 8 Run using the defaults in demo/.env.example. To use another cluster, copy demo/.env.example to demo/.env and fill in your cluster credentials. Machine-specific overrides can go into demo/.env.local. Both files are gitignored — never commit credentials.

Build

Run all tests and build the library:

npm run all

License

MIT

版本与发布记录

@camunda/task-testing 共发布 32 个版本,首次发布于 2025/09/04;过去 12 个月发布了 19 个版本。

版本发布日期距今
7.1.0latest2026/11/072 天前
7.0.12026/10/2217 天前
7.0.02026/10/011 个月前
6.0.12026/08/202 个月前
6.0.02026/08/053 个月前
5.1.02026/06/304 个月前

其他发布通道:next → 3.0.0-rc.0。

关于 @camunda/task-testing 的常见问题

如何安装 @camunda/task-testing?

在项目目录运行 npm install @camunda/task-testing,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)、camunda-bpmn-js(*)、@camunda/design-system(>=0.63.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@camunda/task-testing 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@camunda/task-testing 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@camunda/task-testing 可以商用吗?

@camunda/task-testing 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@camunda/task-testing 的下载量有多少?

根据 npm 官方下载统计,@camunda/task-testing 在 2026/10/09 – 2026/11/07 这 30 天内被下载 14,369 次,日均约 479 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@camunda/task-testing 还在维护吗?

最新版本 7.1.0 发布于 2026/11/07(2 天前);至今共发布 32 个版本,其中过去 12 个月发布了 19 个;首次发布于 2025/09/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。