Receber por email
← Voltar para o catálogo

vitest-testing

**AI-friendly comprehensive testing guidance for Vitest with practical patterns and behavior-driven development.**

367estrelas
Atualizado há 4 meses

Ver no GitHub ↗

Como adicionar

/plugin marketplace add aiskillstore/marketplace

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/vitest-testing/svg)](https://www.skillteca.com.br/skills/vitest-testing)

Skills relacionadas

Ver todas de Segurança →

Alerta por categoria

Receba novas skills de Segurança toda segunda

1 email curto, só com as skills novas de Segurança. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Vitest Testing Skill - Master Reference

AI-friendly comprehensive testing guidance for Vitest with practical patterns and behavior-driven development.

For humans: Start with [README.md](README.md) for full navigation
For AI agents: This file provides quick access to all skill resources

🎯 Quick Access for Agents

Decision Support

  • What type of test should I write? → [index.md](index.md)
  • How do I structure this test? → [principles/aaa-pattern.md](principles/aaa-pattern.md)
  • Is this code testable? → [refactoring/testability-patterns.md](refactoring/testability-patterns.md)

Most Referenced Patterns

  • [F.I.R.S.T Principles](principles/first-principles.md) - Fast, Isolated, Repeatable, Self-Checking, Timely
  • [AAA Pattern](principles/aaa-pattern.md) - Arrange-Act-Assert structure
  • [Black Box Testing](strategies/black-box-testing.md) - Test behavior through public APIs
  • [Test Doubles](patterns/test-doubles.md) - Mocks, stubs, spies, fakes

📚 Skill Organization

Core Principles /principles/

Foundation concepts that guide all testing decisions:

| File | Purpose | When to Use | |------|---------|-------------| | [first-principles.md](principles/first-principles.md) | F.I.R.S.T quality attributes | Every test | | [aaa-pattern.md](principles/aaa-pattern.md) | Arrange-Act-Assert structure | Structuring tests | | [bdd-integration.md](principles/bdd-integration.md) | Given/When/Then with AAA | Business-focused tests |

Testing Strategies /strategies/

Approaches for different testing scenarios:

| File | Purpose | When to Use | |------|---------|-------------| | [black-box-testing.md](strategies/black-box-testing.md) | Testing via public APIs | Default approach (99% of tests) | | [implementation-details.md](strategies/implementation-details.md) | When to test internals | Rare exceptions only |

Practical Patterns /patterns/

Ready-to-use patterns for common scenarios:

| File | Purpose | When to Use | |------|---------|-------------| | [test-doubles.md](patterns/test-doubles.md) | Mocks, stubs, spies, fakes | Isolating dependencies | | [async-testing.md](patterns/async-testing.md) | Testing promises, async/await | Async operations | | [error-testing.md](patterns/error-testing.md) | Testing exceptions, edge cases | Error scenarios | | [component-testing.md](patterns/component-testing.md) | React/Vue component patterns | UI components | | [api-testing.md](patterns/api-testing.md) | HTTP clients, REST APIs | API integration | | [performance-testing.md](patterns/performance-testing.md) | Benchmarks, load testing | Performance-critical code | | [test-data.md](patterns/test-data.md) | Factories, builders, fixtures | Test data management |

Refactoring for Testability /refactoring/

Transform untestable code into testable code:

| File | Purpose | When to Use | |------|---------|-------------| | [testability-patterns.md](refactoring/testability-patterns.md) | Extract pure functions, DI, etc. | Code hard to test |

Quick Reference /quick-reference/

Fast lookups and decision aids:

| File | Purpose | When to Use | |------|---------|-------------| | [cheatsheet.md](quick-reference/cheatsheet.md) | Syntax, matchers, mocking | Quick syntax lookup | | [jest-to-vitest.md](quick-reference/jest-to-vitest.md) | Migration from Jest | Migrating projects |

🤖 Agent Integration Points

For typescript-coder Agent

When writing tests:

// 1. Check decision tree
const testType = checkDecisionTree(codeType)
// Reference: /skills/vitest-testing/index.md

// 2. Apply F.I.R.S.T principles
ensureTestsAreFast()        // < 100ms
ensureTestsAreIsolated()    // No shared state
// Reference: /skills/vitest-testing/principles/first-principles.md

// 3. Use AAA structure
// Arrange → Act → Assert
// Reference: /skills/vitest-testing/principles/aaa-pattern.md

// 4. Follow black box strategy
testThroughPublicAPI()      // Not private methods
// Reference: /skills/vitest-testing/strategies/black-box-testing.md

When refactoring:

// Check if code is testable
if (isHardToTest(code)) {
  // Apply testability patterns
  applyPattern(testabilityPatterns)
  // Reference: /skills/vitest-testing/refactoring/testability-patterns.md
}

For Code Review Agents

Check these aspects:

  • [ ] Tests follow F.I.R.S.T principles
  • [ ] Tests use AAA structure
  • [ ] Tests use black box approach (public APIs only)
  • [ ] Proper mocking of external dependencies
  • [ ] Error scenarios covered
  • [ ] Async operations handled correctly

🎯 Common Workflows

Workflow 1: Writing Tests for New Feature

1. Consult decision tree → /skills/vitest-testing/index.md
2. Determine test type → Unit/Integration/Component
3. Apply F.I.R.S.T principles → /skills/vitest-testing/principles/first-principles.md
4. Structure with AAA → /skills/vitest-testing/principles/aaa-pattern.md
5. Use relevant pattern → /skills/vitest-testing/patterns/
6. Reference examples → /skills/vitest-testing/examples/ (when created)

Workflow 2: Refactoring for Testability

1. Identify pain points → What makes this hard to test?
2. Select pattern → /skills/vitest-testing/refactoring/testability-patterns.md
3. Apply pattern → Extract pure functions, inject dependencies, etc.
4. Write tests → Black box tests for refactored code
5. Verify → All tests pass, code is easier to test

Workflow 3: Testing Async Code

1. Check async patterns → /skills/vitest-testing/patterns/async-testing.md
2. Mock external APIs → /skills/vitest-testing/patterns/test-doubles.md
3. Control timing → Use vi.useFakeTimers()
4. Test states → Loading, success, error
5. Verify cleanup → Resources released

📖 Philosophy

This skill follows these core beliefs:

1. Behavior over Implementation

Tests should verify WHAT the code does, not HOW it does it. Focus on observable outcomes and public contracts. Implementation details should be testable indirectly through public APIs.

2. Example-Driven Learning

Every principle includes practical examples. Before/after refactoring shows impact. Complete examples provide working templates.

3. Testability by Design

Code that's hard to test is poorly designed. Refactoring patterns transform untestable code. Testability improvements enhance overall code quality.

4. F.I.R.S.T Quality

Fast, Isolated, Repeatable, Self-Checking, Timely tests create a valuable safety net that developers trust and maintain.

🔍 Skill Map

vitest-testing/
├── SKILL.md                    ← You are here (AI agent entry point)
├── README.md                   ← Human navigation hub
├── index.md                    ← Decision tree
├── principles/                 ← Testing fundamentals
│   ├── first-principles.md     ← F.I.R.S.T (most important)
│   ├── aaa-pattern.md          ← Test structure
│   └── bdd-integration.md      ← Given/When/Then
├── strategies/                 ← Testing approaches
│   ├── black-box-testing.md    ← Default strategy
│   └── implementation-details.md ← Rare exceptions
├── patterns/                   ← Practical implementations
│   ├── test-doubles.md         ← Mocking (highly referenced)
│   ├── component-testing.md    ← React/UI testing
│   ├── async-testing.md        ← Promises, async/await
│   ├── error-testing.md        ← Error scenarios
│   ├── api-testing.md          ← HTTP/API testing
│   ├── performance-testing.md  ← Benchmarks, load tests
│   └── test-data.md            ← Factories, builders
├── refactoring/                ← Making code testable
│   └── testability-patterns.md ← Extract, inject, isolate
└── quick-reference/            ← Fast lookups
    ├── cheatsheet.md           ← Syntax reference
    └── jest-to-vitest.md       ← Migration guide

🎓 Learning Paths

For Beginners

  1. [F.I.R.S.T Principles](principles/first-principles.md) - Understand quality attributes
  2. [AAA Pattern](princip
Compartilhar X LinkedIn