Overview

Supatest provides a powerful CLI tool that allows you to integrate automated testing into your CI/CD pipelines. This enables you to run test plans automatically as part of your deployment workflow, ensuring your applications are thoroughly tested before reaching production.

Installation

Install the Supatest CLI globally using npm:

npm install -g supatest-ai

Authentication

The CLI requires a Supatest API key for authentication. You can provide it in two ways:

export SUPATEST_API_KEY=your-api-key

Command Line Option

supatest run-plan -p <plan-id> -k <api-key>

Available Commands

Run Test Plan

Execute a test plan and retrieve results:

supatest run-plan --plan-id <planId> [options]

Options:

  • -p, --plan-id <planId>: Test plan ID (required)
  • -e, --env-id <envId>: Environment ID
  • -k, --api-key <apiKey>: Supatest API Key
  • -t, --wait: Wait for results before exiting

Example:

supatest run-plan -p plan_123abc -k sk_test_xxx --wait

Update Environment Variables

Update existing environment variables before running tests:

supatest update-env --env-id <envId> [options] <variables...>

Options:

  • -e, --env-id <envId>: Environment ID (required)
  • -k, --api-key <apiKey>: Supatest API Key

Examples:

# Simple values
supatest update-env -e env_123 DATABASE_URL=postgres://localhost PORT=5432

# Values with spaces
supatest update-env -e env_123 API_URL="https://api.example.com/v1" MESSAGE="Hello World"

Important Notes:

  • Only updates existing variables; does not create new ones
  • All specified variables must exist in the environment
  • Values are always stored as strings
  • Values containing spaces must be wrapped in quotes

CI/CD Integration Examples

GitHub Actions

Create a workflow file at .github/workflows/supatest.yml:

name: Supatest Integration

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

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

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

      - name: Install Supatest CLI
        run: npm install -g supatest-ai

      - name: Run test plan
        run: supatest run-plan -p ${{ secrets.PLAN_ID }} --wait
        env:
          SUPATEST_API_KEY: ${{ secrets.SUPATEST_API_KEY }}

GitLab CI

Add to your .gitlab-ci.yml:

stages:
  - test

supatest:
  stage: test
  image: node:18
  before_script:
    - npm install -g supatest-ai
  script:
    - supatest run-plan -p $PLAN_ID --wait
  variables:
    SUPATEST_API_KEY: $SUPATEST_API_KEY
  only:
    - main
    - develop

Jenkins

pipeline {
    agent any

    environment {
        SUPATEST_API_KEY = credentials('supatest-api-key')
        PLAN_ID = 'plan_123abc'
    }

    stages {
        stage('Setup') {
            steps {
                sh 'npm install -g supatest-ai'
            }
        }

        stage('Run Tests') {
            steps {
                sh 'supatest run-plan -p $PLAN_ID --wait'
            }
        }
    }
}

Azure DevOps

Add to your azure-pipelines.yml:

trigger:
  - main
  - develop

pool:
  vmImage: ubuntu-latest

variables:
  SUPATEST_API_KEY: $(supatest-api-key)
  PLAN_ID: 'plan_123abc'

steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '18.x'
    displayName: 'Install Node.js'

  - script: npm install -g supatest-ai
    displayName: 'Install Supatest CLI'

  - script: supatest run-plan -p $(PLAN_ID) --wait
    displayName: 'Run Test Plan'

Best Practices

1. Environment Management

  • Use different environments for different stages (dev, staging, prod)
  • Update environment variables before running tests to match your deployment
  • Store sensitive information as CI secrets

2. Test Plan Organization

  • Create specific test plans for different deployment stages
  • Use comprehensive test plans for production deployments
  • Consider smoke tests for quick validation

3. Error Handling

  • Use the --wait flag to ensure tests complete before proceeding
  • Check exit codes to determine test success/failure
  • Set up notifications for test failures

4. Security

  • Always use environment variables for API keys
  • Never commit API keys to version control
  • Rotate API keys regularly

Troubleshooting

Common Issues

Unauthorized Error

Error: Unauthorized: Invalid API key
  • Verify your API key is correct
  • Check that the SUPATEST_API_KEY environment variable is set

Variables Not Found

Variables not found: DATABASE_URL, PORT
  • Ensure all variables exist in the specified environment
  • Use the web interface to create missing variables first

Invalid Format

Error: At least one variable in key=value format is required
  • Check variable format: KEY=value
  • Use quotes for values with spaces: KEY="value with spaces"

Getting Help

  • Use supatest --help for command information
  • Use supatest run-plan --help for specific command help
  • Contact support at [support email] for additional assistance