Node ReferenceAssert Node

Assert Node

The Assert Node validates context variables and test state without making API requests. It’s a dedicated testing node that allows you to run assertions independently at any point in your test flow.

Use Cases

  • Context Validation: Verify that context variables have expected values after transformations or calculations.
  • Intermediate State Checks: Validate data between API calls or processing steps.
  • Script Output Validation: Assert that Script Node outputs meet specific criteria.
  • Multi-Step Validation: Break down complex validations into multiple assertion steps for better clarity.
  • Conditional Testing: Use assertion conditions to selectively run validations based on context state.

How It Works

The Assert Node uses the same assertion engine as the API Node, but instead of validating API responses, it validates context variables. All assertion types are supported:

  • Standard Assertions - Built-in operators for common validations (equals, contains, greaterThan, etc.)
  • Custom Assertions - Reusable functions from Script Library
  • Iterator Assertions - Validate arrays/collections
  • Assertion Groups - Predefined assertion sets

For detailed information on assertion types, operators, and syntax, see the Assertions Reference.

Configuration Options

Data Source

Unlike API Node assertions that validate response.data, Assert Node assertions validate context variables directly:

Left: context.userId
Operator: equals
Right: "12345"

Assertion Condition

A JSONata expression that determines whether assertions should run:

context.environment = "production"

If the condition evaluates to false, all assertions are skipped.

Continue on Failure

When enabled, assertion failures are logged but test execution continues. This is useful for:

  • Collecting all validation failures at once
  • Running diagnostic checks without stopping the test
  • Non-critical validations that shouldn’t block execution

Examples

Basic Context Validation

Left: context.userId
Operator: equals
Right: "12345"

Validate multiple properties of a complex object:

Assertion 1: User ID exists
  Left: context.user.id
  Operator: exists

Assertion 2: User email is valid format
  Left: context.user.email
  Operator: isEmail

Assertion 3: User role is correct
  Left: context.user.role
  Operator: equals
  Right: "admin"

Array Validation with Iterator

Validate all items in an array:

Path: context.orders
Assertions:
  - Left: status
    Operator: equals
    Right: "completed"
  - Left: total
    Operator: greaterThan
    Right: 0

This validates that all orders have status “completed” and total > 0.

Custom Assertion from Script Library

Use a predefined custom assertion function for complex validation:

Assertion Type: Custom
Function: isValidDateRange (from Script Library)
Parameters:
  - startDate: context.startDate
  - endDate: context.endDate
  - minDays: 1
  - maxDays: 30

Learn how to create custom assertions in the Assertions Reference.

Conditional Assertions

Only run assertions when a condition is met:

Condition: context.environment = "production"

Assertions:
  - Left: context.securityLevel
    Operator: equals
    Right: "high"

Continue on Failure

Use this when you want to collect all validation failures without stopping:

Continue on Failure: ✓ (enabled)

Assertions:
  - Validate user name format
  - Validate user email format
  - Validate user age range
  - Validate user address

All assertions will run even if some fail, allowing you to see all validation issues at once.

Differences from API Node Assertions

FeatureAPI NodeAssert Node
TriggerRuns after API responseRuns on demand at any point
Data Sourceresponse.data, response.statuscontext.* variables
Primary PurposeValidate API contractValidate intermediate state
Typical UseResponse structure, status, headersTransformed data, script output, state

Best Practices

  • Use standard assertions first: Custom assertions are for complex logic that built-in operators can’t handle.
  • Create reusable custom assertions: Define frequently-used validation logic in Script Library for consistency across tests.
  • Group related assertions: Use Assertion Groups for validations that commonly appear together.
  • Break down complex validations: Instead of one complex assertion, use multiple simpler ones for better error reporting.
  • Leverage iterator assertions: When validating arrays, iterator assertions provide clearer failure messages.
  • Use conditional assertions wisely: Only apply conditions when the validation is truly environment or state-dependent.
  • Enable continue on failure for comprehensive checks: When you want to see all validation issues, not just the first failure.

Execution Behavior

  • Success: All assertions pass → Node completes successfully → Test continues
  • Failure (default): Any assertion fails → Node fails → Test execution stops
  • Failure (continue on failure): Any assertion fails → Failures logged → Test continues

Viewing Results

After execution, the Assert Node’s details panel displays:

  • Statistics: Total assertions, passed count, failed count
  • Detailed Results Table: Each assertion’s result with actual vs. expected values
  • Error Messages: Specific reasons for failures with context

See Also