Back to Skills

Writing Tests

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.

1,025stars79forksUpdated 1/23/2026

Security Assessment

Safe(100/100)
Security Score100/100

About Writing Tests

The 'Writing Tests' skill provides a comprehensive guide for writing and organizing tests in AiderDesk using Vitest and React Testing Library. This skill addresses the need for effective test creation, helping developers write unit tests, integration tests, and component tests with best practices. It ensures that developers can easily validate code quality and functionality through automated testing, ultimately improving reliability and maintainability across projects.

FAQ

How do I start writing tests with Vitest?

You can start by creating a unit test in the file `src/common/__tests__/utils/math.test.ts`. Use the `describe` and `it` blocks from Vitest to structure your test cases. For example, testing a simple math utility function like `add(1, 2)`.

How do I run the tests?

Tests can be run using the command `npm run test` to execute all test cases in the project.

Is mocking supported in the testing process?

Yes, you can use `vi.mock()` for mocking dependencies in your tests, which is especially useful for testing pure functions and isolated logic.

What are the best practices for organizing my tests?

Tests should be organized following the guidelines in the referenced materials, such as test directory structure, naming conventions, and component-specific tests. Check the resources on test organization for further insights.

Are there any additional resources for advanced usage?

Yes, several advanced guides are available, including references on test organization, running tests, and best practices. You can consult these resources for deeper insights into testing strategies.

Install Writing Tests

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill