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 — recommended for local dev):
# For zsh (macOS default)
echo 'export TESTIVAI_API_KEY=your-actual-api-key-here' >> ~/.zshrc
source ~/.zshrc
# For bash
echo 'export TESTIVAI_API_KEY=your-actual-api-key-here' >> ~/.bashrc
source ~/.bashrc -
In CI/CD: Set as environment variable in your pipeline:
# GitHub Actions
env:
TESTIVAI_API_KEY: ${{ secrets.TESTIVAI_API_KEY }}
TestivAI SDKs read only from shell environment variables (process.env). The SDKs do not use dotenv or load .env files. Always use export in your shell or set variables in your CI provider's secrets.
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
Witness SDK
Browser debugging endpoint not found
❌ Browser debugging endpoint not found
Solution: Make sure Chrome is running with remote debugging:
chrome --remote-debugging-port=9222
Connection timeout
❌ Failed to connect to browser: 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 Witness 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
- Witness 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
Witness 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 |
| "Browser 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 hello@testiv.ai
When reporting issues, please include:
- SDK version
- Error message
- Debug logs (if available)
- Steps to reproduce
- Your test framework and version