Skip to content
Back to skills

Workflow Test Write

ASecurity

Написание unit и e2e тестов по методологии TDD (Red → Green → Refactor)

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 20, 2026
developmenttypescriptbashreacttesting

Works with

  • cli

Security analysis

A100/100

Scanned October 20, 2026

npx -y skills add kamiletar/letar --skill workflow-test-write --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Workflow Test Write?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Workflow Test Write
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/kamiletar-workflow-test-write/badge)](https://www.skillsdirectory.com/skills/kamiletar-workflow-test-write)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: workflow-test-write
description: Написание unit и e2e тестов по методологии TDD (Red → Green → Refactor)
---

# Test Write - Написание тестов

Напиши тесты по методологии TDD (Red → Green → Refactor).

## Когда использовать

- Перед написанием новой функциональности (TDD)
- Для покрытия существующего кода
- После исправления бага (регрессионный тест)

## Типы тестов

### Unit тесты (Vitest)

```bash
nx test <app>
nx test <app> --watch
nx test <app> --coverage
```

### E2E тесты (Playwright)

```bash
nx e2e <app>-e2e
nx e2e <app>-e2e --ui
```

## TDD Workflow

1. **Red** — Напиши падающий тест

   ```typescript
   it('should calculate total correctly', () => {
     expect(calculateTotal([100, 200])).toBe(300)
   })
   ```

2. **Green** — Напиши минимальный код для прохождения

   ```typescript
   function calculateTotal(items: number[]) {
     return items.reduce((sum, item) => sum + item, 0)
   }
   ```

3. **Refactor** — Улучши код, сохраняя тесты зелёными

## Паттерны тестирования

### Компоненты React

```typescript
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'

it('should show error on invalid input', async () => {
  render(<MyForm />)
  await userEvent.type(screen.getByRole('textbox'), 'invalid')
  await userEvent.click(screen.getByRole('button'))
  expect(screen.getByText(/ошибка/i)).toBeInTheDocument()
})
```

### Server Actions

```typescript
import { myAction } from './actions'

it('should return data', async () => {
  const result = await myAction({ input: 'test' })
  expect(result.success).toBe(true)
})
```

### ZenStack/Prisma (mock)

```typescript
vi.mock('@/lib/db', () => ({
  prisma: {
    user: {
      findMany: vi.fn().mockResolvedValue([{ id: 1 }]),
    },
  },
}))
```

## Чеклист

- [ ] Тест понятно описывает поведение
- [ ] Тестируются edge cases
- [ ] Нет flaky тестов
- [ ] Покрытие критичных путей

## После написания тестов

1. Обнови PLAN_TESTING.md со статистикой
2. Запусти:
   ```bash
   nx test <app> --coverage
   ```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.