Skip to content

Testing

Overview

Skynet MCP uses Bun's native test runner for all testing. The test suite covers all tool categories with both unit and integration tests.

Running Tests

Run all tests

bash
bun test

Watch mode (auto-rerun on changes)

bash
bun test:watch

Run specific test file

bash
bun test tests/infrastructure.test.ts

Run with coverage (if configured)

bash
bun test --coverage

Test Structure

tests/
├── infrastructure.test.ts  # Docker stack management
├── database.test.ts        # Memgraph & ChromaDB access
├── memory.test.ts          # Semantic memory operations
├── interactions.test.ts    # User interaction tracking
├── cognitive.test.ts       # Skynet workflow
└── integration.test.ts     # End-to-end scenarios

Writing Tests

Basic Test Structure

typescript
import { describe, expect, test } from "bun:test";
import { myFunction } from "../src/tools/myfile";

describe("MyFeature", () => {
  test("should do something", () => {
    const result = myFunction();
    expect(result).toBe(expectedValue);
  });
});

Mocking Databases

typescript
import { describe, expect, test, beforeAll, afterAll } from "bun:test";

describe("DatabaseTests", () => {
  beforeAll(async () => {
    // Setup test database
  });

  afterAll(async () => {
    // Cleanup test database
  });

  test("should query data", async () => {
    // Test implementation
  });
});

Integration Tests

Integration tests require running Docker containers:

typescript
import { describe, expect, test } from "bun:test";

describe.skipIf(!process.env.RUN_INTEGRATION)("Integration Tests", () => {
  test("full workflow", async () => {
    // Test requires Memgraph + ChromaDB running
  });
});

Run with:

bash
RUN_INTEGRATION=1 bun test

Test Guidelines

Unit Tests

  • Test individual functions in isolation
  • Mock external dependencies (databases, Docker)
  • Fast execution (< 100ms per test)
  • No side effects

Integration Tests

  • Test tool interactions end-to-end
  • Require running databases
  • Slower execution acceptable
  • Use describe.skipIf() to skip when containers unavailable

Best Practices

  • Descriptive names: Use clear test descriptions
  • Arrange-Act-Assert: Structure tests clearly
  • Independent tests: No shared state between tests
  • Cleanup: Always clean up test data
  • Edge cases: Test error conditions and boundaries

Current Test Coverage

CategoryTestsStatus
Infrastructure3✅ Passing
Database4✅ Passing
Memory2✅ Passing
Interactions6✅ Passing
Cognitive3✅ Passing
Integration2⏭️ Skipped (requires containers)

Continuous Integration

Tests run automatically on:

  • Every commit (via Git hooks, if configured)
  • Pull requests
  • Main branch pushes

See .github/workflows/ for CI configuration.

Debugging Tests

Verbose output

bash
bun test --verbose

Inspect failures

bash
bun test --bail  # Stop on first failure

Log debugging

typescript
test("debug example", () => {
  console.log("Debug info:", someValue);
  expect(someValue).toBe(expected);
});

Next Steps

Built with Bun + FastMCP + TypeScript