This document provides step-by-step instructions to validate that the comprehensive test suite is working correctly.
The comprehensive test suite includes:
-
Unit Tests: Test individual SDK functions in isolation
auth.test.ts- Authentication and API key managementclient.test.ts- EchoClient SDK functionality
-
CLI Tests: Test CLI commands with mocked dependencies
cli.test.ts- All CLI commands and their behaviors
-
Integration Tests: Test against real server
integration.test.ts- End-to-end workflows
-
Infrastructure: Test setup and utilities
setup.ts- Global test configuration and server managementrun-tests.ts- Standalone test runner
✅ Authentication header inclusion ✅ Balance fetching (general and app-specific) ✅ Payment link creation ✅ Echo app listing and retrieval ✅ URL generation utilities ✅ Error handling (network, auth, timeout)
✅ API key validation (format, length, prefix) ✅ Secure storage operations (store, retrieve, remove) ✅ Error handling for storage failures ✅ Integration scenarios
✅ login - Complete authentication flow
✅ logout - Credential removal
✅ apps / ls - Application listing
✅ balance - Account balance display
✅ payment - Payment link generation
✅ Help and version information
✅ Authentication requirement enforcement
✅ Input validation and error handling
ls -la src/__tests__/Expected files:
auth.test.tsclient.test.tscli.test.tsintegration.test.tssetup.tsrun-tests.tsREADME.md
cat jest.config.jsShould include:
- TypeScript preset
- Test setup file
- Coverage configuration
- Proper timeout settings
npm list --depth=0Should include:
jest,@types/jest,ts-jestdotenv,express,@types/express- All SDK dependencies
npm run test:unitThis tests:
- Authentication module functionality
- SDK client functionality
- No server required
npm run test:cliThis tests:
- All CLI commands
- Mocked dependencies
- No server required
npm run test:integrationThis tests:
- Real server communication
- End-to-end workflows
- Server auto-startup
npm run test:coverageExpected coverage targets:
- Lines: 95%+
- Functions: 100%
- Branches: 90%+
npm run test:allShould run all test types sequentially.
- Jest configuration properly set up
- TypeScript compilation working
- Test dependencies installed
- Mock setup working correctly
- Authentication tests pass
- Client SDK tests pass
- No external dependencies required
- Proper error handling tested
- All CLI commands tested
- Interactive prompts mocked
- Error scenarios covered
- Help and version working
- Server starts automatically
- Real API calls working
- Performance tests pass
- Cleanup working properly
- Coverage reports generated
- Target coverage achieved
- All public APIs covered
- Error paths tested
-
Server startup fails
# Check if port 3001 is available lsof -i :3001 # Kill any processes using the port kill -9 <PID>
-
TypeScript compilation errors
# Build TypeScript explicitly npm run build # Check for type errors npx tsc --noEmit
-
Mock failures
# Clear Jest cache npx jest --clearCache # Run tests with verbose output npx jest --verbose
-
Test timeouts
# Increase timeout in jest.config.js # Or run with longer timeout npx jest --testTimeout=60000
# Run tests with full output
npm test -- --verbose --no-coverage
# Run specific test file
npx jest auth.test.ts
# Run tests matching pattern
npx jest --testNamePattern="authentication"
# Debug server startup
npx ts-node src/__tests__/run-tests.ts --verboseWhen validation is successful, you should see:
Test Suites: 4 passed, 4 total
Tests: 50+ passed, 50+ total
Snapshots: 0 total
Time: 30-60s
Coverage: 95%+ lines, 100% functions
The test suite is designed for CI/CD:
# Example GitHub Actions
- name: Run tests
run: npm run test:ci
# Example for separate test types
- name: Unit tests
run: npm run test:unit
- name: CLI tests
run: npm run test:cli
- name: Integration tests
run: npm run test:integration- Unit tests: < 10 seconds
- CLI tests: < 20 seconds
- Integration tests: < 60 seconds (includes server startup)
- Full suite: < 90 seconds
To maintain test quality:
- Add tests for new features
- Update tests when APIs change
- Monitor coverage reports
- Keep dependencies updated
- Review test performance regularly
The test suite should be run:
- Before every commit
- On pull request creation
- Before releases
- Daily on CI/CD pipeline