Skip to main content
This guide explains how to test GAIA Electron applications and ensure they work correctly with dependency updates.

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

All Electron-related tests live under tests/electron/. Unit tests for framework services sit alongside integration tests for individual apps:

Framework & service tests

  • test_agent_process_manager.js - Backend Python process lifecycle
  • test_notification_service.js - Auto-update and notification plumbing
  • test_electron_framework_integration.js - Cross-module framework wiring
  • test_electron_functional.js - End-to-end Electron smoke tests

App integration tests

  • test_electron_chat_app.js - Chat/Agent UI app
  • test_electron_chat_installer.js - First-run installer flow
  • test_electron_emr_dashboard.js - EMR dashboard
  • test_electron_example_app.js - Example app template verification
  • test_electron_jira_app.js - Jira app configuration and structure
Shared setup lives in tests/electron/setup.js; mocks live under tests/electron/mocks/.

What Gets Tested

Electron Framework

AppController
  • Configuration loading
  • Service initialization
  • MCP connection setup
  • Error handling
  • Lifecycle management
WindowManager
  • Window creation with correct options
  • Preload script loading
  • Event handler setup
  • Window state management
MCPClient
  • WebSocket connection
  • Message sending/receiving
  • Reconnection logic
  • Error handling

Electron Apps

Configuration
  • Valid app.config.json
  • Valid package.json
  • Required dependencies present
  • Version compatibility
Structure
  • Main entry point exists
  • Preload scripts present
  • Required directories exist
  • Build configuration valid
Dependencies
  • 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

  1. test-electron-framework
    • Runs unit tests for core modules
    • Generates code coverage report
    • Uploads coverage artifacts
  2. test-apps-integration
    • Validates app configurations
    • Checks file structure
    • Verifies dependency versions
  3. test-apps-build
    • Tests app packaging
    • Validates npm scripts
    • Checks build configuration
  4. 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

Create tests/electron/test_my_app.js (all Electron tests live under tests/electron/):

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=2 for 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: Ensure moduleNameMapper 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:
  1. Run npm run test:coverage
  2. Open coverage/lcov-report/index.html
  3. Add tests for red-highlighted code
  4. 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
Results are uploaded as artifacts and visible in GitHub Security tab.

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:
  1. Check this guide and README.md in tests/electron/
  2. Review existing test files for examples
  3. Check GitHub Actions logs for CI failures
  4. Ask in team discussions