Troubleshooting
This guide covers common issues and solutions when using TestivAI SDKs and services.
Table of Contentsโ
Authentication Issuesโ
API Key Not Found / Invalid API Keyโ
Symptoms:
- "Invalid API key" error
- "API key not found" error
- Authentication failing even after running
testivai auth
Cause: The testivai auth command validates your key but doesn't export it to your current shell session. Your test runner reads from the TESTIVAI_API_KEY environment variable.
Solutions:
-
Export to current shell session:
export TESTIVAI_API_KEY=your-actual-api-key-here -
Add to shell profile (permanent):
# For zsh
echo 'export TESTIVAI_API_KEY=your-actual-api-key-here' >> ~/.zshrc
# For bash
echo 'export TESTIVAI_API_KEY=your-actual-api-key-here' >> ~/.bashrc
# Reload your shell
source ~/.zshrc # or ~/.bashrc -
Use a .env file (project-specific):
echo "TESTIVAI_API_KEY=your-actual-api-key-here" > .envNote: Make sure your test framework loads .env files (install
dotenvif needed). -
In CI/CD: Set as environment variable in your pipeline:
# GitHub Actions
env:
TESTIVAI_API_KEY: ${{ secrets.TESTIVAI_API_KEY }}
API Key Expiredโ
Symptoms: Authentication was working but suddenly stopped
Solution:
- Check your API key in the dashboard
- Generate a new key if needed
- Update your environment variable
SDK-Specific Issuesโ
Playwright SDKโ
Tests hanging after witness() callโ
- Cause: Promise not resolving due to network issues
- Solution: Check network connectivity and API key validity
"window.testivai is not defined"โ
- Cause: TestivAI not properly imported or test.use() not configured
- Solution: Ensure proper setup in your config file
CDP SDKโ
Chrome DevTools Protocol not foundโ
โ Chrome DevTools Protocol not found
Solution: Make sure Chrome is running with remote debugging:
chrome --remote-debugging-port=9222
Connection timeoutโ
โ Failed to connect to CDP: Connection timeout
Solution:
- Check if Chrome is running
- Verify the port number (default: 9222)
- Check for firewall issues
Cypressโ
"window.testivaiWitness is not a function"โ
- Solution: Ensure CDP SDK is connected before tests run
- Add to cypress.config.js:
chromeWebSecurity: false
CI/CD Issuesโ
GitHub Actionsโ
API key not availableโ
- name: Authenticate
env:
TESTIVAI_API_KEY: ${{ secrets.TESTIVAI_API_KEY }}
run: testivai auth $TESTIVAI_API_KEY
Chrome not starting in CIโ
- name: Start Chrome
run: |
google-chrome \
--remote-debugging-port=9222 \
--no-sandbox \
--disable-dev-shm-usage \
--headless &
Jenkinsโ
Environment variables not passedโ
withCredentials([string(credentialsId: 'testivai-api-key', variable: 'API_KEY')]) {
sh 'export TESTIVAI_API_KEY=$API_KEY'
sh 'testivai run "npm test"'
}
Performance Issuesโ
Tests running slowlyโ
- Use component testing when possible
- Add ignore regions for dynamic content
- Disable animations during tests
- Reduce screenshot size by testing specific components
Memory usage highโ
- Playwright: Reuse browser context between tests
- CDP SDK: Limit concurrent snapshots
- General: Clear test data regularly
Network Issuesโ
Upload timeoutsโ
Symptoms: Captures succeed but upload fails
Solutions:
- Check internet connection
- Verify API key is valid
- Try reducing batch size
- Check if TestivAI service is operational
Proxy issuesโ
If behind a corporate proxy:
# Set proxy environment variables
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=http://proxy.company.com:8080
Debug Modeโ
Enable debug logging to troubleshoot issues:
Playwright SDKโ
DEBUG=testivai:* npx playwright test
CDP SDKโ
DEBUG=testivai:* npm test
# or
testivai run "npm test" --debug
What debug logs show:โ
- API requests and responses
- Capture progress
- Network errors
- Performance metrics
Common Error Messagesโ
| Error | Cause | Solution |
|---|---|---|
| "Invalid API key" | API key not set or invalid | Export TESTIVAI_API_KEY |
| "Project not found" | Wrong project ID | Check dashboard for correct ID |
| "Batch creation failed" | Network or auth issue | Check API key and connection |
| "CDP connection failed" | Chrome not running | Start Chrome with --remote-debugging-port |
| "Snapshot timeout" | Page loading too slow | Increase timeout or check page |
Getting Helpโ
- Check debug logs for detailed error information
- Search existing issues on GitHub
- Join our Discord for community support
- Email support at support@testiv.ai
When reporting issues, please include:
- SDK version
- Error message
- Debug logs (if available)
- Steps to reproduce
- Your test framework and version