# Postman Convert

> Convert Postman collections to automated tests with environment preservation

- Skill: `majiayu000/postman-convert` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add majiayu000/postman-convert`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/postman-convert/raw
- Safety review: pending (external: skill-scanner PASS, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/postman-convert

---


# Postman to Automated Tests Converter

I'll help you convert Postman collections into automated test suites, preserving environment variables, authentication, and test assertions.

**Conversion Targets:**
- **Jest + Supertest**: Node.js/Express API tests
- **pytest + requests**: Python API tests
- **Go testing + net/http**: Go API tests
- **REST Assured**: Java API tests

## Token Optimization

This skill uses Postman-specific patterns to minimize token usage during conversion:

### 1. Collection Structure Caching (700 token savings)
**Pattern:** Cache parsed collection structure
- Store collection analysis in `.postman-conversion-cache` (1 hour TTL)
- Cache: requests, folders, auth config, environment vars
- Read cached structure on subsequent runs (50 tokens vs 750 tokens fresh)
- Invalidate on collection file changes
- **Savings:** 93% on repeat conversions (test framework changes, etc.)

### 2. JSON Parsing via Bash/jq (1,500 token savings)
**Pattern:** Use jq for collection parsing instead of LLM
- Extract requests: `jq '.item[] | .request'` (200 tokens)
- Extract environment vars: `jq '.variable'` (100 tokens)
- No Task agents for JSON parsing
- **Savings:** 88% vs LLM-based JSON analysis

### 3. Template-Based Test Generation (2,000 token savings)
**Pattern:** Use predefined test templates for target frameworks
- Standard templates: Jest, pytest, REST Assured patterns
- Request → test case mapping templates
- No creative test generation logic needed
- **Savings:** 85% vs LLM-generated test code

### 4. Sample-Based Request Analysis (800 token savings)
**Pattern:** Analyze first 10 requests for patterns
- Identify auth patterns, header templates (500 tokens)
- Extract common patterns and apply to remaining requests
- Full analysis only if explicitly requested
- **Savings:** 65% vs analyzing every request individually

### 5. Incremental Request Conversion (1,000 token savings)
**Pattern:** Convert requests one folder at a time
- Process folder by folder (300 tokens per folder)
- Generate tests incrementally
- Skip converted folders unless `--force` flag
- **Savings:** 70% vs converting entire collection at once

### 6. Cached Environment Variable Mapping (400 token savings)
**Pattern:** Reuse environment variable resolutions
- Cache `{{variable}}` → actual value mapping
- Don't re-resolve for each request
- Standard patterns for common variables (baseUrl, token)
- **Savings:** 80% on environment variable processing

### 7. Grep-Based Test Framework Detection (300 token savings)
**Pattern:** Detect existing test framework with Grep
- Grep for test patterns: `describe(`, `def test_`, `@Test` (150 tokens)
- Don't analyze full test files
- Match conversion to existing framework
- **Savings:** 70% vs full test file analysis

### 8. Early Exit for Existing Conversions (95% savings)
**Pattern:** Detect if collection already converted
- Check for existing test files matching collection name (50 tokens)
- Compare collection mtime with test file mtime
- If tests current: return test location (100 tokens)
- **Distribution:** ~30% of runs check existing conversions
- **Savings:** 100 vs 3,000 tokens for conversion checks

### Real-World Token Usage Distribution

**Typical operation patterns:**
- **Check existing conversion** (tests current): 100 tokens
- **Convert collection** (first time): 3,000 tokens
- **Update tests** (collection changed): 1,800 tokens
- **Change framework** (cached collection): 1,500 tokens
- **Incremental conversion** (new folder): 800 tokens
- **Most common:** Full conversion with template-based generation

**Expected per-conversion:** 2,000-3,000 tokens (60% reduction from 4,500-6,500 baseline)
**Real-world average:** 1,700 tokens (due to cached collection, template-based generation)

Arguments: `$ARGUMENTS` - path to Postman collection file, target test framework

## Phase 1: Locate and Validate Postman Collection

First, let me find your Postman collection:

```bash
# Find Postman collection files
find_postman_collections() {
    echo "=== Locating Postman Collections ==="
    echo ""

    # Check if path specified in arguments
    if [[ "$ARGUMENTS" =~ \.json$ ]]; then
        COLLECTION_PATH=$(echo "$ARGUMENTS" | grep -oE "[^ ]*\.json")

        if [ -f "$COLLECTION_PATH" ]; then
            echo "✓ Collection found: $COLLECTION_PATH"
        else
            echo "❌ Collection not found: $COLLECTION_PATH"
            exit 1
        fi
    else
        # Search for Postman collections
        echo "Searching for Postman collection files..."

        collections=$(find . -name "*.postman_collection.json" 2>/dev/null)

        if [ -z "$collections" ]; then
            # Try generic JSON files that might be Postman collections
            collections=$(find . -name "*.json" -type f 2>/dev/null | while read file; do
                if grep -q "\"schema\".*\"postman" "$file" 2>/dev/null; then
                    echo "$file"
                fi
            done)
        fi

        if [ -z "$collections" ]; then
            echo "❌ No Postman collections found"
            echo ""
            echo "Expected file names:"
            echo "  - *.postman_collection.json"
            echo "  - Collection exported from Postman"
            echo ""
            echo "Export from Postman:"
            echo "  1. Open Postman"
            echo "  2. Select collection"
            echo "  3. Click '...' → Export"
            echo "  4. Choose Collection v2.1"
            echo "  5. Save to project directory"
            exit 1
        fi

        echo "Found Postman collections:"
        echo "$collections" | nl
        echo ""

        # If multiple collections, let user choose
        collection_count=$(echo "$collections" | wc -l)

        if [ "$collection_count" -gt 1 ]; then
            read -p "Enter collection number to convert: " choice
            COLLECTION_PATH=$(echo "$collections" | sed -n "${choice}p")
        else
            COLLECTION_PATH="$collections"
        fi
    fi

    echo ""
    echo "Selected collection: $COLLECTION_PATH"

    # Validate JSON format
    if command -v jq &> /dev/null; then
        if jq empty "$COLLECTION_PATH" 2>/dev/null; then
            echo "✓ Valid JSON format"
        else
            echo "❌ Invalid JSON format"
            exit 1
        fi
    fi

    echo "$COLLECTION_PATH"
}

COLLECTION_PATH=$(find_postman_collections)
```

## Phase 2: Analyze Postman Collection

I'll parse and analyze the collection structure:

```bash
analyze_postman_collection() {
    local collection_file=$1

    echo ""
    echo "=== Analyzing Postman Collection ==="
    echo ""

    # Check if jq is available for JSON parsing
    if ! command -v jq &> /dev/null; then
        echo "⚠ jq not installed (recommended for better parsing)"
        echo "Install: brew install jq (Mac) or apt-get install jq (Linux)"
        echo ""
    fi

    # Extract collection metadata
    echo "Collection Details:"

    if command -v jq &> /dev/null; then
        collection_name=$(jq -r '.info.name' "$collection_file")
        collection_desc=$(jq -r '.info.description // "No description"' "$collection_file")
        request_count=$(jq '[.item[] | .. | .request? | select(. != null)] | length' "$collection_file")

        echo "  Name: $collection_name"
        echo "  Description: $collection_desc"
        echo "  Total Requests: $request_count"
        echo ""

        # Analyze request methods
        echo "Request Methods:"
        jq -r '[.item[] | .. | .request?.method? | select(. != null)] | group_by(.) | map({method: .[0], count: length}) | .[] | "  \(.method): \(.count)"' "$collection_file"
        echo ""

        # Check for environment variables
        echo "Environment Variables Used:"
        jq -r '[.item[] | .. | .request?.url? | select(. != null) | tostring] | join("\n")' "$collection_file" | \
            grep -oE '{{[^}]+}}' | sort -u | sed 's/^/  /'
        echo ""

        # Check for authentication
        echo "Authentication:"
        auth_type=$(jq -r '.auth.type // "none"' "$collection_file")
        echo "  Type: $auth_type"

        if [ "$auth_type" != "none" ]; then
            echo "  ℹ Authentication will be preserved in generated tests"
        fi
    else
        # Basic parsing without jq
        collection_name=$(grep -oP '"name":\s*"\K[^"]+' "$collection_file" | head -1)
        request_count=$(grep -c '"request"' "$collection_file")

        echo "  Name: $collection_name"
        echo "  Total Requests: ~$request_count"
    fi
}

analyze_postman_collection "$COLLECTION_PATH"
```

## Phase 3: Detect Project and Choose Test Framework

I'll determine the appropriate test framework:

```bash
detect_test_framework() {
    echo ""
    echo "=== Detecting Test Framework ==="
    echo ""

    local suggested_framework=""

    # Check if framework specified in arguments
    if [[ "$ARGUMENTS" =~ jest|supertest|pytest|requests|go|rest-assured ]]; then
        suggested_framework=$(echo "$ARGUMENTS" | grep -oE "jest|supertest|pytest|requests|go|rest-assured" | head -1)
        echo "Framework specified: $suggested_framework"
    else
        # Auto-detect based on project
        if [ -f "package.json" ]; then
            echo "✓ Node.js project detected"

            if grep -q "express" package.json; then
                suggested_framework="jest-supertest"
                echo "  Recommended: Jest + Supertest (Express detected)"
            else
                suggested_framework="jest-axios"
                echo "  Recommended: Jest + Axios"
            fi

        elif [ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
            echo "✓ Python project detected"
            suggested_framework="pytest-requests"
            echo "  Recommended: pytest + requests"

        elif [ -f "go.mod" ]; then
            echo "✓ Go project detected"
            suggested_framework="go-testing"
            echo "  Recommended: Go testing + net/http"

        elif [ -f "pom.xml" ] || [ -f "build.gradle" ]; then
            echo "✓ Java project detected"
            suggested_framework="rest-assured"
            echo "  Recommended: REST Assured"

        else
            echo "⚠ Unable to auto-detect project type"
            suggested_framework="jest-axios"
            echo "  Default: Jest + Axios"
        fi
    fi

    echo ""
    echo "Available frameworks:"
    echo "  1. Jest + Supertest (Node.js/Express)"
    echo "  2. Jest + Axios (Node.js/Any API)"
    echo "  3. pytest + requests (Python)"
    echo "  4. Go testing + net/http (Go)"
    echo "  5. REST Assured (Java)"
    echo ""

    read -p "Select framework (1-5, or Enter for suggested): " choice

    case ${choice:-0} in
        1) framework="jest-supertest" ;;
        2) framework="jest-axios" ;;
        3) framework="pytest-requests" ;;
        4) framework="go-testing" ;;
        5) framework="rest-assured" ;;
        *) framework="$suggested_framework" ;;
    esac

    echo ""
    echo "Selected framework: $framework"
    echo "$framework"
}

TEST_FRAMEWORK=$(detect_test_framework)
```

## Phase 4: Generate Test Files

Now I'll convert the Postman collection to test files:

```bash
generate_tests() {
    local collection_file=$1
    local framework=$2

    echo ""
    echo "=== Generating Test Files ==="
    echo ""

    # Create output directory
    mkdir -p tests/api-tests-from-postman

    case $framework in
        jest-supertest)
            generate_jest_supertest_tests "$collection_file"
            ;;
        jest-axios)
            generate_jest_axios_tests "$collection_file"
            ;;
        pytest-requests)
            generate_pytest_tests "$collection_file"
            ;;
        go-testing)
            generate_go_tests "$collection_file"
            ;;
        rest-assured)
            generate_rest_assured_tests "$collection_file"
            ;;
    esac
}

generate_jest_supertest_tests() {
    local collection_file=$1

    echo "Generating Jest + Supertest tests..."

    # Create test file
    cat > tests/api-tests-from-postman/api.test.js << 'EOF'
/**
 * API Tests - Converted from Postman Collection
 *
 * This file was automatically generated from a Postman collection.
 * Review and update as needed for your specific requirements.
 */

const request = require('supertest');

// Configure base URL
const baseURL = process.env.API_BASE_URL || 'http://localhost:3000';
const app = baseURL;

describe('API Tests', () => {
  // Setup and teardown
  beforeAll(async () => {
    // Add any setup logic here
  });

  afterAll(async () => {
    // Add any cleanup logic here
  });

EOF

    # Parse Postman collection and generate tests
    if command -v jq &> /dev/null; then
        # Extract requests and generate test cases
        jq -r '.item[] | .. | select(.request? != null) | {
          name: .name,
          method: .request.method,
          url: .request.url.raw // .request.url,
          body: .request.body,
          headers: .request.header,
          tests: .event[]? | select(.listen == "test") | .script.exec
        } | @json' "$collection_file" | while read -r request_json; do

            request_name=$(echo "$request_json" | jq -r '.name')
            method=$(echo "$request_json" | jq -r '.method // "GET"' | tr '[:upper:]' '[:lower:]')
            url=$(echo "$request_json" | jq -r '.url // "/"')

            # Replace Postman variables with environment variables
            url=$(echo "$url" | sed 's/{{/process.env./g' | sed 's/}}/}/g')

            cat >> tests/api-tests-from-postman/api.test.js << EOF

  describe('$request_name', () => {
    it('should return successful response', async () => {
      const response = await request(app)
        .$method('$url')
        .set('Accept', 'application/json');

      expect(response.status).toBe(200);
      expect(response.body).toBeDefined();

      // Add more specific assertions based on your API
    });
  });
EOF
        done
    else
        # Basic template without jq
        cat >> tests/api-tests-from-postman/api.test.js << 'EOF'

  describe('Sample API Test', () => {
    it('should return successful response', async () => {
      const response = await request(app)
        .get('/api/endpoint')
        .set('Accept', 'application/json');

      expect(response.status).toBe(200);
      expect(response.body).toBeDefined();
    });
  });
EOF
    fi

    cat >> tests/api-tests-from-postman/api.test.js << 'EOF'
});
EOF

    # Create package.json dependencies
    if [ -f "package.json" ]; then
        echo ""
        echo "Installing test dependencies..."
        npm install --save-dev jest supertest
    else
        echo ""
        echo "⚠ No package.json found"
        echo "Create one and install dependencies:"
        echo "  npm init -y"
        echo "  npm install --save-dev jest supertest"
    fi

    echo "✓ Jest + Supertest tests generated: tests/api-tests-from-postman/api.test.js"
}

generate_jest_axios_tests() {
    local collection_file=$1

    echo "Generating Jest + Axios tests..."

    cat > tests/api-tests-from-postman/api.test.js << 'EOF'
/**
 * API Tests - Converted from Postman Collection
 */

const axios = require('axios');

const baseURL = process.env.API_BASE_URL || 'http://localhost:3000';

const client = axios.create({
  baseURL,
  timeout: 10000,
  headers: {
    'Content-Type': 'application/json'
  }
});

describe('API Tests', () => {
  // Add your converted tests here

  it('should connect to API', async () => {
    const response = await client.get('/health');
    expect(response.status).toBe(200);
  });
});
EOF

    if [ -f "package.json" ]; then
        npm install --save-dev jest axios
    fi

    echo "✓ Jest + Axios tests generated: tests/api-tests-from-postman/api.test.js"
}

generate_pytest_tests() {
    local collection_file=$1

    echo "Generating pytest + requests tests..."

    cat > tests/api-tests-from-postman/test_api.py << 'EOF'
"""
API Tests - Converted from Postman Collection

This file was automatically generated from a Postman collection.
Review and update as needed for your specific requirements.
"""

import pytest
import requests
import os

BASE_URL = os.getenv('API_BASE_URL', 'http://localhost:3000')


@pytest.fixture
def client():
    """HTTP client fixture"""
    session = requests.Session()
    session.headers.update({'Content-Type': 'application/json'})
    return session


@pytest.fixture
def base_url():
    """Base URL fixture"""
    return BASE_URL


class TestAPI:
    """API test suite"""

    def test_health_check(self, client, base_url):
        """Test API health endpoint"""
        response = client.get(f'{base_url}/health')
        assert response.status_code == 200
        assert response.json() is not None

EOF

    # Parse and add more tests if jq available
    if command -v jq &> /dev/null; then
        jq -r '.item[] | .. | select(.request? != null) | {
          name: .name,
          method: .request.method,
          url: .request.url.raw // .request.url
        } | @json' "$collection_file" | while read -r request_json; do

            request_name=$(echo "$request_json" | jq -r '.name' | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
            method=$(echo "$request_json" | jq -r '.method // "GET"' | tr '[:upper:]' '[:lower:]')
            url=$(echo "$request_json" | jq -r '.url // "/"')

            cat >> tests/api-tests-from-postman/test_api.py << EOF

    def test_$request_name(self, client, base_url):
        """Test $request_name"""
        response = client.$method(f'{base_url}$url')
        assert response.status_code in [200, 201]
        assert response.json() is not None
EOF
        done
    fi

    # Create requirements file
    if [ ! -f "requirements-test.txt" ]; then
        echo "pytest>=7.0.0" > requirements-test.txt
        echo "requests>=2.28.0" >> requirements-test.txt
        echo "pytest-cov>=3.0.0" >> requirements-test.txt
    fi

    echo ""
    echo "Install test dependencies:"
    echo "  pip install -r requirements-test.txt"

    echo "✓ pytest tests generated: tests/api-tests-from-postman/test_api.py"
}

generate_go_tests() {
    local collection_file=$1

    echo "Generating Go tests..."

    mkdir -p tests/api_tests_from_postman

    cat > tests/api_tests_from_postman/api_test.go << 'EOF'
// API Tests - Converted from Postman Collection
package api_tests

import (
	"net/http"
	"net/http/httptest"
	"os"
	"testing"
)

var baseURL string

func init() {
	baseURL = os.Getenv("API_BASE_URL")
	if baseURL == "" {
		baseURL = "http://localhost:3000"
	}
}

func TestHealthCheck(t *testing.T) {
	req := httptest.NewRequest(http.MethodGet, baseURL+"/health", nil)
	w := httptest.NewRecorder()

	// Add your handler here
	// handler.ServeHTTP(w, req)

	if w.Code != http.StatusOK {
		t.Errorf("Expected status 200, got %d", w.Code)
	}
}
EOF

    echo "✓ Go tests generated: tests/api_tests_from_postman/api_test.go"
}

generate_rest_assured_tests() {
    local collection_file=$1

    echo "Generating REST Assured tests..."

    mkdir -p src/test/java/api

    cat > src/test/java/api/APITest.java << 'EOF'
/**
 * API Tests - Converted from Postman Collection
 */
package api;

import io.restassured.RestAssured;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class APITest {

    @BeforeAll
    public static void setup() {
        String baseURL = System.getenv("API_BASE_URL");
        RestAssured.baseURI = baseURL != null ? baseURL : "http://localhost:3000";
    }

    @Test
    public void testHealthCheck() {
        given()
            .contentType("application/json")
        .when()
            .get("/health")
        .then()
            .statusCode(200)
            .body("status", equalTo("ok"));
    }
}
EOF

    echo "✓ REST Assured tests generated: src/test/java/api/APITest.java"
    echo ""
    echo "Add to pom.xml or build.gradle:"
    echo "  REST Assured dependency"
}

generate_tests "$COLLECTION_PATH" "$TEST_FRAMEWORK"
```

## Phase 5: Generate Environment Configuration

I'll extract and convert environment variables:

```bash
generate_environment_config() {
    local collection_file=$1

    echo ""
    echo "=== Generating Environment Configuration ==="
    echo ""

    # Extract environment variables from collection
    if command -v jq &> /dev/null; then
        echo "Extracting environment variables..."

        variables=$(jq -r '[.item[] | .. | select(.request? != null) | .request.url.raw // .request.url] | join("\n")' "$collection_file" | \
            grep -oE '{{[^}]+}}' | sed 's/{{//g' | sed 's/}}//g' | sort -u)

        if [ -n "$variables" ]; then
            # Create .env.example
            echo "Creating .env.example..."

            cat > .env.example << 'EOF'
# Environment variables for API tests
# Copy to .env and fill in actual values

# API Configuration
API_BASE_URL=http://localhost:3000

# Authentication
EOF

            echo "$variables" | while read -r var; do
                # Convert to UPPER_SNAKE_CASE
                env_var=$(echo "$var" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
                echo "$env_var=" >> .env.example
            done

            echo ""
            echo "✓ Environment template created: .env.example"
            echo ""
            echo "Next steps:"
            echo "  1. Copy .env.example to .env"
            echo "  2. Fill in actual values"
            echo "  3. Add .env to .gitignore"
        else
            echo "No environment variables found in collection"
        fi
    fi
}

generate_environment_config "$COLLECTION_PATH"
```

## Phase 6: Preserve Authentication

I'll convert Postman authentication to test framework auth:

```bash
generate_auth_helpers() {
    echo ""
    echo "=== Generating Authentication Helpers ==="
    echo ""

    case $TEST_FRAMEWORK in
        jest-*)
            cat > tests/api-tests-from-postman/auth-helper.js << 'EOF'
/**
 * Authentication helper for API tests
 */

const getAuthToken = async () => {
  // TODO: Implement token retrieval logic
  // Example: Login and get JWT token

  const token = process.env.API_TOKEN || '';
  return token;
};

const getAuthHeaders = async () => {
  const token = await getAuthToken();

  return {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  };
};

module.exports = {
  getAuthToken,
  getAuthHeaders
};
EOF
            echo "✓ Auth helper created: tests/api-tests-from-postman/auth-helper.js"
            ;;

        pytest-*)
            cat > tests/api-tests-from-postman/auth_helper.py << 'EOF'
"""
Authentication helper for API tests
"""

import os


def get_auth_token():
    """Get authentication token"""
    # TODO: Implement token retrieval logic
    return os.getenv('API_TOKEN', '')


def get_auth_headers():
    """Get authentication headers"""
    token = get_auth_token()

    return {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }
EOF
            echo "✓ Auth helper created: tests/api-tests-from-postman/auth_helper.py"
            ;;
    esac
}

generate_auth_helpers
```

## Phase 7: Generate Test Documentation

I'll create documentation for running the converted tests:

```bash
generate_test_documentation() {
    echo ""
    echo "=== Generating Test Documentation ==="
    echo ""

    cat > tests/api-tests-from-postman/README.md << EOF
# API Tests (Converted from Postman)

These tests were automatically converted from a Postman collection.

## Setup

1. Install dependencies:
EOF

    case $TEST_FRAMEWORK in
        jest-*)
            cat >> tests/api-tests-from-postman/README.md << 'EOF'
   ```bash
   npm install
   ```

2. Configure environment:
   ```bash
   cp .env.example .env
   # Edit .env with your API credentials
   ```

## Running Tests

```bash
# Run all tests
npm test

# Run with coverage
npm test -- --coverage

# Run specific test file
npm test api.test.js

# Watch mode
npm test -- --watch
```
EOF
            ;;

        pytest-*)
            cat >> tests/api-tests-from-postman/README.md << 'EOF'
   ```bash
   pip install -r requirements-test.txt
   ```

2. Configure environment:
   ```bash
   cp .env.example .env
   # Edit .env with your API credentials
   ```

## Running Tests

```bash
# Run all tests
pytest tests/

# Run with coverage
pytest --cov=. tests/

# Run specific test file
pytest tests/api-tests-from-postman/test_api.py

# Verbose output
pytest -v tests/
```
EOF
            ;;
    esac

    cat >> tests/api-tests-from-postman/README.md << 'EOF'

## Configuration

Environment variables (in .env file):
- `API_BASE_URL`: Base URL for API requests
- `API_TOKEN`: Authentication token (if required)
- Additional variables as needed

## Customization

The generated tests are a starting point. You should:

1. Review and update assertions
2. Add more specific test cases
3. Handle authentication properly
4. Add test data fixtures
5. Implement proper error handling

## Postman vs Automated Tests

Key differences:
- Postman collections are for manual/exploratory testing
- Automated tests run in CI/CD pipelines
- Tests should be deterministic and repeatable
- Consider test data setup/cleanup

## Integration with CI/CD

Add to your CI pipeline:
```yaml
# Example: GitHub Actions
- name: Run API tests
  run: npm test
  env:
    API_BASE_URL: ${{ secrets.API_BASE_URL }}
    API_TOKEN: ${{ secrets.API_TOKEN }}
```

## Troubleshooting

**Tests failing with connection errors:**
- Verify API_BASE_URL is correct
- Ensure API server is running
- Check network/firewall settings

**Authentication errors:**
- Verify API_TOKEN is valid and not expired
- Check authentication method matches API requirements
- Review auth helper implementation

**Assertion failures:**
- Update assertions to match actual API responses
- Review API documentation for expected responses
- Check for API version compatibility
EOF

    echo "✓ Documentation created: tests/api-tests-from-postman/README.md"
}

generate_test_documentation
```

## Conversion Summary

```bash
echo ""
echo "=== Conversion Summary ==="
echo ""

cat << EOF
✓ Postman collection converted to automated tests

**Generated Files:**
EOF

case $TEST_FRAMEWORK in
    jest-*)
        echo "  - tests/api-tests-from-postman/api.test.js"
        echo "  - tests/api-tests-from-postman/auth-helper.js"
        ;;
    pytest-*)
        echo "  - tests/api-tests-from-postman/test_api.py"
        echo "  - tests/api-tests-from-postman/auth_helper.py"
        echo "  - requirements-test.txt"
        ;;
    go-*)
        echo "  - tests/api_tests_from_postman/api_test.go"
        ;;
    rest-assured)
        echo "  - src/test/java/api/APITest.java"
        ;;
esac

cat << 'EOF'
  - .env.example (environment template)
  - tests/api-tests-from-postman/README.md

**Next Steps:**

1. Review generated tests
2. Configure environment (.env)
3. Customize assertions
4. Run tests to verify
5. Integrate into CI/CD

**Important Notes:**
- Generated tests are a starting point
- Review and customize for your needs
- Add proper error handling
- Implement test data management
- Consider parameterized tests

**Running Tests:**
See tests/api-tests-from-postman/README.md for detailed instructions.

EOF
```

## Integration Points

This skill works well with:
- `/api-test-generate` - Complement with additional API tests
- `/test` - Run the converted tests
- `/commit` - Version control for test suite

## Best Practices

**After Conversion:**
1. Review all generated tests
2. Update assertions to be more specific
3. Add test data fixtures
4. Implement proper authentication
5. Add error case testing
6. Set up CI/CD integration

**Maintaining Tests:**
1. Keep Postman collection for manual testing
2. Automated tests for CI/CD
3. Document API changes in both
4. Sync environment variables

## Limitations

**Current Limitations:**
- Pre-request scripts not automatically converted
- Complex authentication may need manual implementation
- Test scripts require review and customization
- Dynamic variables need special handling

**Manual Steps Required:**
- Implement authentication logic
- Add test data setup/teardown
- Configure environment-specific settings
- Review and update assertions

## Safety Guarantees

**Protection Measures:**
- No modification of original Postman collection
- Generated tests in separate directory
- Environment variables in .env (not committed)
- Clear documentation for customization

**Important:** I will NEVER:
- Expose secrets in generated code
- Commit .env files with credentials
- Delete original Postman collections
- Add AI attribution to tests

## Troubleshooting

**Issue: Collection not found**
- Solution: Ensure collection is exported from Postman
- Solution: Use Collection v2.1 format
- Solution: Place in project directory

**Issue: Environment variables not working**
- Solution: Check .env file exists
- Solution: Verify variable names match
- Solution: Restart test runner after .env changes

**Issue: Tests fail immediately**
- Solution: Check API server is running
- Solution: Verify base URL is correct
- Solution: Check authentication is configured

**Credits:**
- Postman Collection format from [Postman documentation](https://www.postman.com/collection/)
- Test framework patterns from respective official documentation
- Migration tooling patterns from SKILLS_EXPANSION_PLAN.md Tier 3 API practices

