This document describes how to run integration tests against a real incident.io instance.
The project includes two types of tests:
- Unit tests - Fast, mocked tests that run on every commit (109 tests)
- Integration tests - Real API calls to incident.io that validate actual behavior
Integration tests are optional and require a real incident.io API key.
- Access to an incident.io workspace (test or development environment recommended)
- An API key from incident.io API settings
- An alert source ID from your incident.io dashboard
Set the required environment variables:
export INCIDENT_IO_API_KEY="your-test-api-key-here"
export INCIDENT_IO_ALERT_SOURCE_ID="your-alert-source-id-here"Or create a .env file (already gitignored):
INCIDENT_IO_API_KEY=your-test-api-key-here
INCIDENT_IO_ALERT_SOURCE_ID=your-alert-source-id-hereRun only the integration tests:
npm run test:integrationOr run all tests including integration:
npm testIf INCIDENT_IO_API_KEY or INCIDENT_IO_ALERT_SOURCE_ID is not set,
integration tests will be skipped automatically.
- Go to your repository Settings → Secrets and variables → Actions
- Add repository secrets:
INCIDENT_IO_API_KEY- Your test API keyINCIDENT_IO_ALERT_SOURCE_ID- Your alert source ID
- Use a test workspace (not production)
Integration tests run via a manual workflow trigger:
- Go to Actions → Integration Tests
- Click Run workflow
- Optionally select a test severity level
- Click Run workflow button
The workflow will:
- Run API integration tests (tests/incident-api.test.ts)
- Test the action end-to-end with various configurations
- Test template variable expansion
- Create real test alerts in your incident.io instance
The integration workflow tests:
-
API Client Tests
- Connection validation
- Alert creation with minimal fields
- Alert creation with all optional fields
- Different severity levels
- Deduplication behavior
- Metadata handling
- Error handling
- Rate limiting
-
Action end-to-end Tests
- Minimal alert creation
- Full-featured alert with templates and custom fields
- Custom template variables
All test alerts are clearly marked:
- Titles start with
[E2E Test]or[Integration Test] - Contain metadata identifying them as test alerts
- Use unique deduplication keys to avoid interference
You can clean up test alerts in your incident.io dashboard after running tests.
- Use a test or development incident.io workspace, not production
- Integration tests create real alerts - they're not free operations
- Run integration tests before major releases to validate API contracts
- Store
INCIDENT_IO_API_KEYas a repository secret - Use a dedicated test workspace or sandbox environment
- Integration tests should run on:
- Manual trigger (current setup)
- Before releases (recommended)
- After significant API client changes
- Never commit API keys to the repository
- Use
.envfiles locally (already in.gitignore) - Use GitHub secrets for CI/CD
- Use a test workspace API key with limited permissions if possible
If you see "Skipping integration test - INCIDENT_IO_API_KEY or INCIDENT_IO_ALERT_SOURCE_ID not set":
-
Verify the environment variables are set:
echo $INCIDENT_IO_API_KEY echo $INCIDENT_IO_ALERT_SOURCE_ID
-
Ensure they are exported if running in a shell
-
In CI, verify both secrets exist in repository settings
If tests fail with connection errors:
- Verify the API key is valid
- Check your incident.io workspace is accessible
- Verify network connectivity to
api.incident.io - Check incident.io service status
If you hit rate limits:
- Wait a few minutes before re-running
- The client automatically retries with exponential backoff
- Consider reducing test frequency
If test alerts accidentally reach production:
- They're clearly marked with
[E2E Test]or[Integration Test]prefixes - They contain
"test": truein custom fields for easy filtering - Review your API key - ensure it's for a test workspace
Potential improvements for the integration testing setup:
- Automatic cleanup - Delete test alerts after test completion
- PR testing - Optionally run integration tests on PRs
- Scheduled runs - Daily integration tests to catch API changes
- Test repository - Separate repository testing realistic workflow scenarios
- Performance benchmarks - Track alert creation latency over time