> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mira-app.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing

> Run the Python test suite and understand the testing strategy for MIRA.

MIRA currently has a Python test suite covering the RLM reasoning engine. TypeScript tests for the Electron main process and renderer are scaffolded (Jest is configured in `jest.config.json`) but not yet written — contributions welcome.

## TypeScript tests (Jest)

### Configuration

`jest.config.json` is at the project root. The test environment is `node` and the pattern matches `**/__tests__/**/*.test.ts` and `**/?(*.)+(spec|test).ts` files co-located with source files.

### Running (once tests exist)

```bash theme={null}
# Run all tests
npm test

# Run in watch mode
npm run test:watch

# Run with coverage
npm run test:coverage
```

### Mocking strategy

When tests are added, the established mock pattern is:

* `better-sqlite3` — mock with an in-memory database in test setup
* `electron` — mocked via `src/__mocks__/electron.ts` (already present)
* `keytar` / `safeStorage` — mock to avoid OS encryption calls in CI

***

## Python tests (pytest)

The RLM engine (`rlm/`) has a test suite using pytest.

### Running tests

```bash theme={null}
# Activate your virtual environment first
source .venv/bin/activate   # macOS/Linux
# .venv\Scripts\activate    # Windows

# Run all RLM Python tests
pytest rlm/tests/ -v

# Run with coverage
pytest rlm/tests/ --cov=rlm/rlm_context --cov-report=term-missing
```

### Test files

| File                            | Coverage focus                            |
| ------------------------------- | ----------------------------------------- |
| `rlm/tests/test_rlm.py`         | Core RLM iteration control, state machine |
| `rlm/tests/test_integration.py` | End-to-end loop execution                 |
| `rlm/tests/test_advanced.py`    | Adapter correctness, edge cases           |
| `rlm/tests/test_e2e.py`         | Full query-to-response pipelines          |

### Test fixtures

Test documents and sample data are in `rlm/tests/`.

<Note>
  The NAE engine (`resources/nae_context/`) does not yet have its own test suite. Its correctness is
  covered indirectly by the RLM integration tests and manual QA.
</Note>
