Agent Skills: Writing Tests

Write unit tests, component tests, and integration tests for AiderDesk using Vitest and React Testing Library. Use when creating new tests, adding test coverage, configuring mocks, setting up test files, or debugging failing tests.

UncategorizedID: hotovo/aider-desk/writing-tests

Repository

hotovoLicense: Apache-2.0
1,11793

Install this agent skill to your local

pnpm dlx add-skill https://github.com/hotovo/aider-desk/tree/HEAD/.aider-desk/skills/writing-tests

Skill Files

Browse the full folder contents for writing-tests.

Download Skill

Loading file tree…

.aider-desk/skills/writing-tests/SKILL.md

Skill Metadata

Name
writing-tests
Description
Write unit tests, component tests, and integration tests for AiderDesk using Vitest and React Testing Library. Use when creating new tests, adding test coverage, configuring mocks, setting up test files, or debugging failing tests.

Writing Tests

Write effective tests using Vitest and React Testing Library.

Quick Start

Create a unit test in packages/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.

Core Patterns

Unit Testing

Focus on pure functions and logic in src/main or packages/common. Use vi.mock() for dependencies.

Component Testing

Test React components in src/renderer. Focus on user interactions and props.

Mocking

Use centralized mock factories for consistent testing across components and contexts.

Debugging Failing Tests

  1. Read the error output and identify the failing assertion
  2. Check mock setup — verify vi.mock() paths and return values match expectations
  3. For component tests, inspect rendered output with screen.debug()
  4. Run a single test in isolation: npm run test:node -- --no-color -t "test name"
  5. Verify coverage: npm run test:coverage to confirm new code is tested

Advanced Usage

For detailed information: