Principle:Langgenius Dify Node Level Testing
| Knowledge Sources | |
|---|---|
| Domains | Workflow Testing Debugging |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Node-level testing is the practice of executing individual workflow nodes in isolation with user-supplied test inputs, enabling incremental debugging and validation of node behavior before committing to a full workflow execution.
Description
Complex workflows can contain dozens of interconnected nodes, making full end-to-end execution expensive and difficult to debug. Node-level testing addresses this by allowing developers to run a single node within the draft workflow context, providing test inputs that simulate what the node would receive from its upstream connections.
Single Node Execution: The core capability is running one node at a time. The developer selects a node on the canvas, provides input values through a test form, and triggers execution. The backend processes just that node using the current draft configuration and returns the results, including outputs, execution time, and any errors.
Iteration and Loop Node Testing: Iteration nodes (which process each element of a list through a sub-graph) and loop nodes (which repeat a sub-graph until a condition is met) have specialized execution endpoints. These nodes require different handling because they orchestrate multiple internal executions and produce aggregate results. The URL construction for these node types includes the flow mode (standard or advanced-chat) to ensure correct routing.
Result Caching: The system caches the results of the most recent node execution. When a developer re-opens a node's test panel, the last run results are automatically loaded, allowing them to review previous outputs without re-executing. This is particularly valuable for nodes that call external services (LLMs, APIs) where re-execution may incur cost or latency.
Execution Tracing: Each node run produces a NodeTracing result that captures comprehensive execution metadata: the node's status (succeeded, failed, exception), wall-clock elapsed time, the actual inputs received, the outputs produced, and any error information. This tracing data enables detailed debugging of node behavior.
Usage
Node-level testing is used during:
- Initial development: Testing each node as it is added to the workflow to verify correct configuration
- Debugging: Isolating a failing node to determine whether the issue is in its configuration, its inputs, or an external dependency
- Iteration: Rapidly tweaking node parameters and re-running to observe the effect without executing upstream nodes
- Validation: Confirming that a node produces expected outputs for known inputs before connecting it into the broader graph
Theoretical Basis
Unit Testing Analogy
Node-level testing in a visual workflow builder is analogous to unit testing in traditional software development. Each node is treated as an isolated unit with defined inputs and outputs. Just as a unit test provides mock inputs and asserts on outputs, the node test runner accepts user-provided inputs and displays the resulting outputs and status.
Traditional Unit Test:
function add(a, b) => a + b
test: add(2, 3) => expect(5)
Node-Level Test:
LLM Node (prompt: "Summarize: {{text}}")
test: { text: "Long article..." } => { summary: "Brief summary..." }
Execution Model
The single node run follows this execution flow:
[Developer provides test inputs]
|
v
[POST /workflows/draft/nodes/{nodeId}/run]
|
v
[Backend: Load draft graph context]
|
v
[Backend: Execute target node with provided inputs]
|
v
[Return NodeTracing result]
|-- status: succeeded | failed | exception
|-- elapsed_time: number (seconds)
|-- inputs: Record<string, any>
|-- outputs: Record<string, any>
|-- error: string | null
|
v
[Cache result as "last run" for this node]
|
v
[Display results in test panel]
Specialized Execution Paths
Iteration and loop nodes require different execution endpoints because they manage internal sub-graph execution:
Standard Node:
POST {prefix}/{flowId}/workflows/draft/nodes/{nodeId}/run
Iteration Node:
SSE {prefix}/{flowId}/[advanced-chat/]workflows/draft/iteration/nodes/{nodeId}/run
Loop Node:
SSE {prefix}/{flowId}/[advanced-chat/]workflows/draft/loop/nodes/{nodeId}/run
Iteration and loop nodes use Server-Sent Events (SSE) rather than standard POST responses because they produce streaming results as each iteration or loop cycle completes, providing real-time feedback to the developer.