Elffuss BraidHub

kikocis/continue public

main · 4.9 KiBSourceRawPermalink

Testing Strategies

This document provides an overview of the different testing strategies used in this repository, when to use each type, and links to examples.

Test Types

1. Unit Tests

Purpose: Test individual functions, utilities, and modules in isolation.

When to use:

Framework: Vitest with TypeScript support

Examples:

How to run: npm test (includes linting)

2. Service Tests

Purpose: Test service classes and dependency injection system.

When to use:

Examples:

3. UI Component Tests

Purpose: Test React components using Ink testing library for terminal UI.

When to use:

Framework: Vitest + Ink Testing Library + React Testing utilities

Examples:

Test Checklist: See src/ui/UI_TEST_CHECKLIST.md for comprehensive UI testing guidelines.

4. E2E (End-to-End) Tests

Purpose: Test complete user workflows and CLI behavior in realistic scenarios.

When to use:

Examples:

Testing Infrastructure

Test Helpers

Service Container Testing:

CLI Testing:

Mocks

UI Mocks: src/ui/__mocks__/

Service Mocks: src/__mocks__/

Configuration

Vitest Configuration: vitest.config.ts

Running Tests

# Run all tests with linting
npm test

# Run tests in watch mode
npx vitest --watch

# Run specific test file
npx vitest src/util/formatError.test.ts

# Run tests with coverage
npx vitest --coverage

Best Practices

  1. Unit Tests: Focus on pure functions and isolated logic

  2. Service Tests: Test dependency injection and service lifecycle

  3. UI Tests: Test user-visible behavior, not implementation details

  4. E2E Tests: Test complete user workflows and CLI behavior

  5. Keep tests focused: One behavior per test

  6. Use descriptive names: Test names should explain what's being tested

  7. Minimal mocking: Only mock external dependencies and APIs

  8. Test error cases: Include negative test cases and edge conditions

  9. Maintain test isolation: Each test should be independent