CI Integration
Integrate Supatest into your CI/CD pipelines using the CLI
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:
Authentication
The CLI requires a Supatest API key for authentication. You can provide it in two ways:
Environment Variable (Recommended)
Command Line Option
Available Commands
Run Test Plan
Execute a test plan and retrieve results:
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:
Update Environment Variables
Update existing environment variables before running tests:
Options:
-e, --env-id <envId>
: Environment ID (required)-k, --api-key <apiKey>
: Supatest API Key
Examples:
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
:
GitLab CI
Add to your .gitlab-ci.yml
:
Jenkins
Azure DevOps
Add to your azure-pipelines.yml
:
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
- Verify your API key is correct
- Check that the
SUPATEST_API_KEY
environment variable is set
Variables Not Found
- Ensure all variables exist in the specified environment
- Use the web interface to create missing variables first
Invalid Format
- 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