Source Code:
tests/electron/ | src/gaia/electron/Overview
GAIA uses automated testing to validate Electron framework and applications:- Unit Tests: Test individual components in isolation
- Integration Tests: Verify app structure and configuration
- Build Tests: Ensure apps can be packaged correctly
- Dependency Audits: Check for security vulnerabilities
Quick Start
Running Tests Locally
Test Structure
Framework Tests (tests/electron/)
Unit tests for core Electron framework modules:
test_app_controller.js- AppController lifecycle and initializationtest_window_manager.js- Window creation and managementtest_mcp_client.js- WebSocket communication and MCP protocol
App Tests (tests/apps/)
Integration tests for Electron apps:
test_jira_app.js- Jira app configuration and structuretest_example_app.js- Example app template verification
What Gets Tested
Electron Framework
✅ AppController- Configuration loading
- Service initialization
- MCP connection setup
- Error handling
- Lifecycle management
- Window creation with correct options
- Preload script loading
- Event handler setup
- Window state management
- WebSocket connection
- Message sending/receiving
- Reconnection logic
- Error handling
Electron Apps
✅ Configuration- Valid
app.config.json - Valid
package.json - Required dependencies present
- Version compatibility
- Main entry point exists
- Preload scripts present
- Required directories exist
- Build configuration valid
- Compatible Electron version
- No high-severity vulnerabilities
- Matching framework versions
- Valid npm scripts
GitHub Actions Integration
Automated Testing Workflow
Tests run automatically on:- Pull Requests: Changes to Electron framework or apps
- Dependency Updates: Dependabot PRs
- Main Branch: After merges
- Manual Trigger: Via GitHub Actions UI
Workflow Jobs
-
test-electron-framework
- Runs unit tests for core modules
- Generates code coverage report
- Uploads coverage artifacts
-
test-apps-integration
- Validates app configurations
- Checks file structure
- Verifies dependency versions
-
test-apps-build
- Tests app packaging
- Validates npm scripts
- Checks build configuration
-
dependency-audit
- Scans for vulnerabilities
- Generates audit reports
- Uploads results as artifacts
Testing New Apps
When creating a new Electron app, follow these steps:1. Create App Structure
2. Add Dependabot Configuration
Edit.github/dependabot.yml:
3. Create Integration Tests
Createtests/apps/test_my_app.js:
4. Update Test Workflow
Add your app to.github/workflows/test_electron.yml:
5. Verify Tests
Debugging Tests
Enable Debug Output
VS Code Debugging
Add to.vscode/launch.json:
Continuous Integration Best Practices
1. Run Tests Before Committing
2. Monitor Test Results
- Check GitHub Actions tab for PR status
- Review test artifacts for failures
- Examine coverage reports
3. Keep Tests Fast
- Mock expensive operations
- Use
--maxWorkers=2for CI - Skip E2E tests in unit test runs
4. Update Tests with Code Changes
- Add tests for new features
- Update tests when refactoring
- Maintain coverage thresholds
Common Issues
Issue: Cannot find module ‘electron’
Cause: Electron is mocked in tests but import path is incorrect Solution: EnsuremoduleNameMapper is configured in package.json:
Issue: Tests timeout
Cause: Async operations not completing or no timeout set Solution:Issue: Coverage below threshold
Cause: Uncovered code paths Solution:- Run
npm run test:coverage - Open
coverage/lcov-report/index.html - Add tests for red-highlighted code
- Or adjust thresholds in
package.json
Security Audits
Running Audits Manually
Automated Audits
Security audits run automatically in CI:- On every PR
- Weekly scheduled scans
- After dependency updates
Advanced Testing
E2E Testing with Spectron
For full end-to-end testing:Performance Testing
Monitor app startup time and memory usage:Resources
Getting Help
If you encounter issues:- Check this guide and README.md in tests/electron/
- Review existing test files for examples
- Check GitHub Actions logs for CI failures
- Ask in team discussions