Comprehensive guide for writing unit tests, integration tests, and component tests in AiderDesk using Vitest. Use when creating new tests, configuring mocks, or organizing test files.
Review Score
16%
Validation Score
11/16
Implementation Score
0%
Activation Score
0%
Write effective tests using Vitest and React Testing Library.
Create a unit test in src/common/__tests__/utils/math.test.ts:
import { describe, it, expect } from 'vitest';
import { add } from '../../utils/math';
describe('math utility', () => {
it('adds two numbers correctly', () => {
expect(add(1, 2)).toBe(3);
});
});Run tests with npm run test.
Focus on pure functions and logic in src/main or src/common. Use vi.mock() for dependencies.
Test React components in src/renderer. Focus on user interactions and props.
Use centralized mock factories for consistent testing across components and contexts.
For detailed information: