writing tests

Write effective tests using Vitest and React Testing Library.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "writing tests" with this command: npx skills add hotovo/aider-desk/hotovo-aider-desk-writing-tests

Writing Tests

Write effective tests using Vitest and React Testing Library.

Quick Start

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 .

Core Patterns

Unit Testing

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

  • references/unit-testing-examples.md

Component Testing

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

  • references/component-testing-patterns.md

Mocking

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

  • references/mocking-guide.md - Mock factories and API patterns

Debugging Failing Tests

  • Read the error output and identify the failing assertion

  • Check mock setup — verify vi.mock() paths and return values match expectations

  • For component tests, inspect rendered output with screen.debug()

  • Run a single test in isolation: npm run test:node -- --no-color -t "test name"

  • Verify coverage: npm run test:coverage to confirm new code is tested

Advanced Usage

For detailed information:

  • references/test-organization.md - Directory structure and naming

  • references/running-tests.md - CLI commands and coverage

  • references/best-practices.md - Principles and patterns

  • references/test-patterns.md - Code templates

  • assets/test-checklist.md - Pre-flight checklist

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

skill-creator

No summary provided by upstream source.

Repository SourceNeeds Review
General

theme-factory

No summary provided by upstream source.

Repository SourceNeeds Review
General

extension-creator

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

agent-creator

No summary provided by upstream source.

Repository SourceNeeds Review