This guide provides information about how to run tests and how to structure new tests for the Debug MCP Server.
For running GitHub Actions workflows locally (especially container tests), we use Act.
- Docker: Ensure Docker is installed and running
- Act: Install Act following the official instructions
- Docker Image: Build the MCP debugger Docker image:
docker build -t mcp-debugger:local .
- CRITICAL: Run Act inside WSL2 (required for Docker operations)
- Ensure Docker Desktop WSL2 integration is enabled
- Open WSL2 terminal and run Act from there
- Do NOT run Act from Windows CMD/PowerShell
- The
.actrcfile already includes--container-architecture linux/amd64 - Alternatively, build multi-arch images for
mcp-debugger:local
With the updated .actrc configuration, Act will:
- Use your local
catthehacker/ubuntu:act-latestimage - Default to the CI workflow (to avoid running both workflows)
- Not pull images from the registry
# Simple commands (using helper scripts):
./scripts/act-test.sh ci # Linux/macOS
scripts\act-test.cmd ci # Windows
# Run CI workflow tests (default)
act -j build-and-test --matrix os:ubuntu-latest
# Run only E2E tests
./scripts/act-test.sh e2e
# Run Release workflow tests
act -W .github/workflows/release.yml -j build-and-testNote: The CI workflow runs on every push/PR, while the Release workflow only runs when you create version tags (e.g., v1.0.0).
The project includes an .actrc file with optimized settings:
- Uses Docker-enabled runner images (
catthehacker/ubuntu:act-latest) - Enables
--bindfor proper volume mounting - Enables
--privilegedfor Docker daemon access - Sets container architecture for cross-platform compatibility
The project uses Vitest as the testing framework. There are several scripts available to run tests:
npm testtests/runners/run-tests.cmd unittests/runners/run-tests.cmd integrationtests/runners/run-tests.cmd e2etests/runners/dev-test.cmdThis interactive script:
- Builds the project
- Restarts the MCP server with debug logging
- Provides options to run unit, integration, E2E, or all tests
- Allows keeping the server running for development
tests/runners/run-tests.cmd unit path/to/test/file.test.tsThe tests are organized into three main categories:
- Unit Tests: Tests individual components in isolation by mocking their dependencies
- Integration Tests: Tests interactions between multiple components
- E2E Tests: Tests the entire application flow
tests/
├── e2e/ # End-to-end tests
├── fixtures/ # Test data and fixtures
│ └── python/ # Python scripts for testing
├── integration/ # Integration tests
├── mocks/ # Mock implementations for testing
├── runners/ # Test runner scripts
├── test-utils/ # Test utility functions and helpers
│ ├── helpers/ # Helper scripts (port-manager, test-setup, etc.)
│ ├── mocks/ # Mock implementations (dap-client, logger, etc.)
│ └── fixtures/ # Test fixtures (python scripts, etc.)
├── unit/ # Unit tests
│ ├── debugger/ # Tests for debugger components
│ ├── session/ # Tests for session management
│ └── utils/ # Tests for utility functions
└── vitest.setup.ts # Vitest setup configuration
When writing tests, follow these guidelines:
- Mock all external dependencies
- Test a single responsibility
- Use descriptive test names
- Structure tests with arrange-act-assert pattern
- For tests involving the DAP protocol, use the mock DAP client
- Mock external services (like debugpy server)
- Test interactions between components
- Focus on component boundaries
- Minimize mocking
- Test complete workflows from user perspective
When running tests that involve network connections, port conflicts can occur. To avoid this:
- Use random port numbers for tests
- Ensure ports are released after each test
- Use the global
testPortManagerto manage port allocation
Tests requiring Python need the Python interpreter to be available. Ensure your system has Python installed and available in the PATH.
Many operations in the Debug MCP Server are asynchronous. When testing:
- Always await async functions
- Use Vitest's async test support (async/await in test functions)
- Be careful with timeouts
The project aims for high test coverage. Run the coverage report with:
npm run test:coverageFocus on improving coverage in critical areas like:
- Debug protocol implementation
- Session management
- Error handling
For debugging failing tests:
- Use the
--debugflag with Vitest - Add console logs in tests (they will appear in test output)
- Examine the log files in the
logs/directory
When container tests fail:
- Check if the Docker image exists:
docker images | grep mcp-debugger - Verify Act environment:
echo $ACT(should be "true" when running in Act) - Check Docker daemon access:
docker ps - Review container logs in test output
-
"Script path not found" errors: Usually indicates volume mount issues
- Ensure
.actrcincludes--bindflag - Check that paths are relative, not absolute
- Ensure
-
"spawn node ENOENT" errors: Node.js not found in PATH
- The Python discovery test now handles Act environment automatically
- For other tests, ensure proper PATH configuration
-
Docker command failures: Docker not available in Act container
- Ensure using
catthehacker/ubuntu:act-latestimages (as configured in.actrc) - Verify
--privilegedflag is set
- Ensure using
If Act proves problematic for your environment, consider using the Testcontainers library as an alternative approach for container-based testing.