--- description: Testing conventions for Rust and TypeScript globs: "**/*.test.{ts,tsx}" alwaysApply: false --- # Testing Conventions ## Rust Tests (cargo test) - In-module `#[cfg(test)]` blocks using `Database::in_memory()` - Test naming: `snake_case` describing behavior (e.g. `trim_preserves_pinned_entries`) - All tests must pass before committing: `cd src-tauri && cargo test` ## Frontend Tests (Vitest) - Use `@testing-library/react` with `jsdom` environment - Mock Tauri APIs in `src/test/setup.ts` — never call real IPC in tests - Use `makeEntry()` and `makeSettings()` factories for test data - Call `resetIdCounter()` in `beforeEach` when IDs matter - When testing async Tauri commands, use `waitFor()` assertions - Guard `scrollIntoView` with optional chaining (`el?.scrollIntoView?.()`) since jsdom doesn't implement it ## Running Tests ```bash cd src-tauri && cargo test # Rust: 27 tests npx vitest run # Frontend: 47 tests ```