Skip to main content

Package Manager

Install SemanticTest using your preferred package manager:
npm install @blade47/semantic-test

Environment Setup

Optional: OpenAI API Key

If you want to use the LLMJudge block for semantic validation, you’ll need an OpenAI API key.
1

Get an API Key

Sign up at OpenAI Platform and create an API key
2

Create .env file

Create a .env file in your project root:
.env
OPENAI_API_KEY=sk-proj-your-key-here
3

Load environment variables

The CLI automatically loads .env files. For programmatic usage:
import 'dotenv/config';
All other blocks work without any API keys!

Verify Installation

Create a simple test file to verify installation:
test.json
{
  "name": "Installation Test",
  "tests": [{
    "id": "verify",
    "pipeline": [{
      "block": "MockData",
      "config": {
        "data": { "message": "Hello, SemanticTest!" }
      },
      "output": "result"
    }],
    "assertions": {
      "result.message": "Hello, SemanticTest!"
    }
  }]
}
Run it:
npx semtest test.json
You should see:
✅ Installation Test
  ✅ verify (5ms)
     ✅ result.message = "Hello, SemanticTest!"

1 test passed, 0 failed

Project Structure

We recommend organizing your tests like this:
your-project/
├── tests/
│   ├── api/
│   │   ├── users.json
│   │   └── auth.json
│   ├── ai/
│   │   ├── chat.json
│   │   └── tools.json
│   └── integration/
│       └── e2e.json
├── .env
└── package.json

Next Steps

I