Skip to main content

What are Blocks?

Blocks are the building pieces of test pipelines. Each block does one thing well and can be combined with other blocks to create complex test scenarios.

Available Blocks

Block Categories

HTTP & Data Fetching

  • HttpRequest: Make API calls
  • MockData: Test without external dependencies

Parsing & Transformation

  • JsonParser: Parse JSON responses
  • StreamParser: Handle streaming data

Validation

  • ValidateContent: Text and content validation
  • ValidateTools: AI tool call validation
  • LLMJudge: Semantic validation with AI

Control Flow

  • Loop: Retry logic and iterations

Common Patterns

API Testing

{
  "pipeline": [
    { "block": "HttpRequest" },   // Call API
    { "block": "JsonParser" },    // Parse response
    { "block": "ValidateContent" } // Validate content
  ]
}

AI Agent Testing

{
  "pipeline": [
    { "block": "HttpRequest" },    // Call AI API
    { "block": "StreamParser" },   // Parse streaming response
    { "block": "ValidateTools" },  // Check tool calls
    { "block": "LLMJudge" }        // Semantic validation
  ]
}

Retry Logic

{
  "pipeline": [
    { "id": "request", "block": "HttpRequest" },
    { "block": "ValidateContent" },
    {
      "block": "Loop",
      "config": {
        "target": "request",
        "maxIterations": 3
      }
    }
  ]
}

Creating Custom Blocks

Don’t see what you need? Create custom blocks:
import { Block } from '@blade47/semantic-test';

export class MyCustomBlock extends Block {
  static get inputs() {
    return {
      required: ['data'],
      optional: ['config']
    };
  }

  static get outputs() {
    return {
      produces: ['result']
    };
  }

  async process(inputs, context) {
    // Your logic here
    return { result: processedData };
  }
}

Learn More About Custom Blocks

Complete guide to creating and registering custom blocks

Block Composition

Blocks are designed to be composable. Here are common combinations:
HttpRequest → JsonParser → ValidateContent → Assertions
HttpRequest → StreamParser → ValidateTools → LLMJudge → Assertions
HttpRequest → ValidateContent → Loop (if failed) → Assertions
MockData → ValidateContent → LLMJudge → Assertions

Next Steps

I