This directory contains unit tests for the integration repository.
Install dependencies:
npm installRun all tests:
npm testRun tests in watch mode:
npm run test:watchRun tests with coverage:
npm run test:coverage-
helpers/- Test utilities and mock data generatorsmock-allure-results.ts- Generates mock Allure test result datatest-utils.ts- File system and test utilities
-
report.test.ts- Tests for report generation functionality and Slack notifications in the report flow- Tests happy path (no Slack call when tests pass)
- Tests failure scenarios (Slack called when tests fail)
- Tests exception handling (Slack called when exceptions occur)
-
validation.test.ts- Tests for validation functions -
release-cleanup.test.ts- Tests for draft release cleanup logic -
slack.test.ts- Unit tests for Slack notification function itself (message format, webhook handling) -
integration.test.ts- Full flow integration tests
The test suite uses mocked Allure result files to simulate SDK test runs. Each mock result includes:
uuid- Unique test identifierstatus- Test status (passed, failed, broken, skipped)testCaseId- Test case identifierlabels- Allure labels (suite, feature, epic, etc.)
import { generateMockRunnerResults } from './helpers/mock-allure-results';
// Generate mock results for a runner
const results = generateMockRunnerResults('sdk-ts', {
passed: 10,
failed: 2,
broken: 1,
skipped: 1
});The test suite includes comprehensive tests for Slack notifications:
-
slack.test.ts: Unit tests for the Slack notification function itself
- Message formatting and content validation
- Webhook configuration handling
- Error handling (network failures, missing webhook)
- Support for all component types
-
report.test.ts: Integration tests for Slack notifications in the report generation flow
- ✅ Happy path: All tests pass → Slack NOT called
- ✅ Test failures: Tests fail → Slack called
- ✅ Exception during SDK execution: Missing results directory → Slack called
- ✅ Exception during report generation: Allure generation fails → Slack called
- ✅ Release component failures: Both draft and final releases
- ✅ Multiple runner failures: Handles mixed results correctly
- ✅ Test statistics validation: Broken tests treated as failures
- ✅ Slack message sent when tests fail (
executionPassed = false) - ✅ Slack message NOT sent when tests pass (
executionPassed = true) - ✅ Slack message sent when exceptions occur (
exceptionOccurred = true) - ✅ Slack message handling when webhook is missing (graceful skip)
- ✅ Slack message handling when fetch fails (error re-thrown)
- ✅ Slack notifications for all component types:
- Release (including draft releases)
- SDK components (sdk-ts, sdk-swift, sdk-kmp)
- Service components (cloud-agent, mediator)
- Weekly component
- ✅ Exception handling during report generation
- ✅ Multiple runner failure scenarios
- ✅ Test statistics validation (failed/broken tests)
The test suite has been enhanced with:
- Error Path Testing: Comprehensive tests for error scenarios and edge cases
- Version Parsing Tests: Edge case validation for semantic versioning
- Race Condition Tests: Validation of concurrent runner processing
- Type Safety: All test mocks use proper TypeScript interfaces
- Test Utilities: Reusable helpers for mock data generation and file system management
The test suite uses helper functions to generate mock Allure results:
import { generateMockRunnerResults } from './helpers/mock-allure-results';
const results = generateMockRunnerResults('sdk-ts', {
passed: 10,
failed: 2,
broken: 1,
skipped: 1
});Temporary directories are managed automatically:
import { createTempDir, cleanupTempDir } from './helpers/test-utils';
const tempDir = createTempDir('test-');
// ... use tempDir for tests
cleanupTempDir(tempDir); // Cleanup in afterEachWhen adding new tests:
- Use descriptive test names that explain what is being tested
- Group related tests in
describeblocks - Use
beforeEach/afterEachfor setup/cleanup - Mock external dependencies using
vi.mock() - Test both happy paths and error scenarios
- Include edge cases and boundary conditions