CI/CD Setup Guide

Integrate Symulate into your CI/CD pipeline (Jenkins, GitHub Actions, GitLab CI)

Overview

Symulate has two generation modes that work differently in CI/CD:

ModeSpeedCostNetworkUse Case
AI ModeSlower (API calls)Consumes tokensRequiredDevelopment, staging
Faker ModeFast (local)FREEOfflineCI/CD, testing

For CI/CD: Always use Faker mode

Recommended Strategy

The Optimal Workflow

Development (Local)
├─ Use AI mode to generate realistic schemas once
├─ Cache the schema structure in your repo
└─ Commit schema files to version control

CI/CD Pipeline
├─ Use Faker mode (no API calls, unlimited, fast)
├─ Generate test data from cached schemas
└─ Run tests with fresh data every time

Why this works:

  • No API calls in CI/CD = fast builds
  • No token consumption = unlimited test runs
  • Works offline (important for private networks)
  • Reproducible tests with seeds
  • Zero cost for testing

Jenkins Setup

Faker Mode (Recommended for CI/CD)

Jenkinsfile:

pipeline {
    agent any

    environment {
        // Optional: Set to 'faker' to ensure Faker mode
        SYMULATE_MODE = 'faker'
        // Optional: Seed for reproducible test data
        SYMULATE_SEED = '12345'
    }

    stages {
        stage('Install Dependencies') {
            steps {
                sh 'npm ci'
            }
        }

        stage('Run Tests') {
            steps {
                // Tests will use Faker mode (no API calls)
                sh 'npm test'
            }
        }

        stage('Integration Tests') {
            steps {
                // Integration tests with mock data
                sh 'npm run test:integration'
            }
        }
    }

    post {
        always {
            junit 'test-results/**/*.xml'
        }
    }
}

Key Points:

  • No SYMULATE_API_KEY needed
  • Faker mode is used automatically
  • Fast execution (~10ms per generation)
  • No quota consumption

GitHub Actions Setup

.github/workflows/test.yml:

name: Test Suite

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]

jobs:
  test:
    runs-on: ubuntu-latest

    env:
      # Force Faker mode in CI (no API calls)
      SYMULATE_FORCE_FAKER: true
      # Reproducible test data
      SYMULATE_SEED: 12345

    steps:
      - uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Run unit tests
        run: npm test

      - name: Run integration tests
        run: npm run test:integration

      - name: Upload coverage
        uses: codecov/codecov-action@v3
        with:
          files: ./coverage/coverage-final.json

GitLab CI Setup

.gitlab-ci.yml:

stages:
  - test
  - integration
  - deploy

variables:
  # Global: Force Faker mode
  SYMULATE_FORCE_FAKER: "true"
  SYMULATE_SEED: "12345"

# Unit tests with Faker mode
test:unit:
  stage: test
  image: node:18
  script:
    - npm ci
    - npm test
  coverage: '/Lines\s*:\s*(\d+\.\d+)%/'
  artifacts:
    reports:
      junit: test-results/junit.xml

# Integration tests with Faker mode
test:integration:
  stage: integration
  image: node:18
  script:
    - npm ci
    - npm run test:integration
  only:
    - merge_requests
    - main

SDK Configuration

Environment-Aware Configuration

symulate.config.ts:

import { SymulateConfig } from '@symulate/sdk';

const isCI = process.env.CI === 'true';
const isTest = "production" === 'test';

export default {
  // Auto-detect: Faker in CI/tests, AI in development
  mode: isCI || isTest ? 'faker' : 'auto',

  // API key (only needed for AI mode)
  apiKey: process.env.SYMULATE_API_KEY,

  // Seed for reproducible tests
  seed: isTest ? 12345 : undefined,

  // Cache AI-generated schemas
  cacheSchemas: !isCI,
  cacheDir: '.symulate/schemas',

  // Log mode for debugging
  debug: process.env.SYMULATE_DEBUG === 'true',
} satisfies SymulateConfig;

Best Practices

1. Use Faker Mode for All CI/CD Tests

# Good: Fast, free, offline
SYMULATE_MODE=faker npm test

# Bad: Slow, costs tokens, requires network
SYMULATE_MODE=ai npm test

2. Seed Your Tests for Reproducibility

// Reproducible: Same data every test run
const users = await mockend.generate({
  schema: userSchema,
  seed: 12345, // Always generates same data
});

// Random: Different data every run (harder to debug)
const users = await mockend.generate({
  schema: userSchema,
  // No seed = random data
});

3. Cache Schemas, Not Data

// Good: Cache schema structure
await fs.writeFile('schemas/user.json', JSON.stringify(schema));

// Bad: Don't cache the actual data
// Data should be generated fresh for each test

4. Separate Dev and CI Configs

{
  "scripts": {
    "test": "SYMULATE_MODE=faker jest",
    "test:dev": "SYMULATE_MODE=auto jest",
    "test:ci": "SYMULATE_FORCE_FAKER=true jest"
  }
}

5. Use Jenkins Credentials for API Keys

environment {
    // Store in Jenkins credentials, not in code
    SYMULATE_API_KEY = credentials('mockend-api-key')
}

Cost Optimization

Faker-First Approach

Development → AI mode (1 time)
    ↓
Generate schema
    ↓
Commit schema to repo
    ↓
CI/CD → Faker mode (unlimited runs)

Cost: ~$0.01 per schema (one-time) + $0 for all CI/CD runs

Tiered Testing

  • Unit Tests (1000s of runs/day) → Faker mode: FREE
  • Integration Tests (100s of runs/day) → Faker mode: FREE
  • E2E Tests (10s of runs/day) → AI mode: ~$0.10/day
  • Production Data Generation → AI mode: Pay as needed

Performance Comparison

MetricFaker ModeAI Mode
Speed~10ms~500-2000ms
NetworkNoneRequired
Cost$0~$0.001-0.01/call
QuotaUnlimitedLimited by plan
OfflineWorksFails
CI/CDPerfectAvoid

Conclusion: For CI/CD pipelines, Faker mode is always the right choice.

Summary

For Jenkins and all CI/CD pipelines:

  1. Use Faker mode - Fast, free, offline, unlimited
  2. Seed your tests - Reproducible results
  3. Cache schemas - Generate with AI once, use Faker forever
  4. No API keys in CI - Faker mode doesn't need them
  5. Save AI for staging/prod - Where realism matters

Your pipeline will be:

  • Faster - No API calls
  • Cheaper - No token consumption
  • More reliable - No network dependencies
  • Scalable - Run 1000s of tests without limits

Need more examples?

Check out framework-specific integration guides for React, Vue, and Angular.

View Examples →