🎯

testing

🎯Skill

from bumgeunsong/daily-writing-friends

VibeIndex|
What it does

Enforces output-based testing of pure functions, guiding developers to write testable code by focusing on functional core transformations.

πŸ“¦

Part of

bumgeunsong/daily-writing-friends(12 items)

testing

Installation

git cloneClone repository
git clone https://github.com/BumgeunSong/daily-writing-friends.git
npm runRun npm script
npm run dev
πŸ“– Extracted from docs: bumgeunsong/daily-writing-friends
1Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

Use when writing tests, adding coverage, implementing business logic, or building features with TDD. Enforces output-based testing of pure functions only - never test imperative shell directly.

Overview

# Output-Based Testing for Pure Functions

Test pure functions with input/output assertions. Never unit test hooks, components, or side effects.

When to Use

  • User asks to "write tests" or "add coverage"
  • New business logic is being implemented
  • TDD requested for new feature
  • Coverage report shows untested utils/

Core Pattern

```

TESTABLE (Functional Core) β”‚ NOT UNIT TESTED (Imperative Shell)

───────────────────────────────│────────────────────────────────────

Pure functions in utils/ β”‚ React hooks (useX)

Calculations, transformations β”‚ Components (*.tsx)

Validators, formatters β”‚ API calls, Firebase operations

State machines, reducers β”‚ localStorage, Date.now(), Math.random()

```

Implementation

What to Test

```typescript

// βœ… TESTABLE: Pure function

export const calculateStreak = (dates: Date[], today: Date): number => {

// Pure transformation: dates β†’ number

};

// Test with simple input/output

describe('calculateStreak', () => {

it('returns 0 for empty dates', () => {

expect(calculateStreak([], new Date('2024-01-15'))).toBe(0);

});

it('returns consecutive days count', () => {

const dates = [new Date('2024-01-14'), new Date('2024-01-15')];

expect(calculateStreak(dates, new Date('2024-01-15'))).toBe(2);

});

});

```

What NOT to Test

```typescript

// ❌ DON'T TEST: Hook with side effects

export function useStreak(userId: string) {

const { data } = useQuery(['streak', userId], () => fetchStreak(userId));

return calculateStreak(data?.dates ?? [], new Date());

}

// ❌ DON'T TEST: Component

const StreakBadge = ({ userId }) => {

const streak = useStreak(userId);

return {streak} days;

};

```

TDD Workflow

```

  1. Write failing test for pure function
  2. Implement pure function to pass test
  3. Create thin hook/component that calls pure function
  4. Skip unit tests for hook/component (E2E covers integration)

```

Test File Location

```

src/

β”œβ”€β”€ feature/

β”‚ β”œβ”€β”€ utils/

β”‚ β”‚ β”œβ”€β”€ calculations.ts # Pure functions

β”‚ β”‚ └── calculations.test.ts # Tests here

β”‚ β”œβ”€β”€ hooks/

β”‚ β”‚ └── useFeature.ts # NO unit tests

β”‚ └── components/

β”‚ └── Feature.tsx # NO unit tests

```

Common Mistakes

| Mistake | Symptom | Fix |

|---------|---------|-----|

| Testing hooks | renderHook(), QueryClientProvider in test | Extract logic to pure function |

| Mocking time | vi.useFakeTimers(), mockDate | Inject timestamp as parameter |

| Mocking internals | vi.mock('../api/firebase') | Test pure logic, not integration |

| Testing UI | render(), screen.getByText() | Only E2E tests for UI |

Red Flags

Stop and refactor if your test file has:

  • vi.mock() for anything except external APIs
  • renderHook() or render() from testing-library
  • QueryClient, Provider, or wrapper setup
  • More than 5 lines of test setup

Naming Convention

```typescript

describe('FeatureName', () => {

describe('when [condition]', () => {

it('[expected outcome]', () => {

// Arrange - Act - Assert (max 3-5 lines)

});

});

});

```

More from this repository10

🎯
refactoring🎯Skill

Refactors code by extracting pure functions from side-effect-laden logic, enabling easier testing and maintainability.

🎯
code-style🎯Skill

Enforces clean, readable code by providing guidelines for function design, naming conventions, and code clarity principles.

🎯
react-hook🎯Skill

I apologize, but I cannot generate a description without seeing the specific details about the "react-hook" skill from the repository. Could you provide more context or details about what this part...

🎯
pr-stacking🎯Skill

Enables developers to break large features into smaller, dependent PRs for incremental development and easier code reviews.

🎯
daily-writing-friends-design🎯Skill

Provides a comprehensive design system for Daily Writing Friends, ensuring consistent UI components, styling, and accessibility across the application.

🎯
api-layer🎯Skill

Manages API interactions and request handling for the Daily Writing Friends application, facilitating communication between frontend and backend services.

🎯
skill-creator🎯Skill

Guides developers in designing Claude Skills using progressive disclosure, optimizing skill architecture and content creation.

🎯
fetching-pr-comments🎯Skill

Retrieves and parses GitHub PR review comments for the current branch using GitHub CLI, enabling quick review of code-level feedback.

🎯
firebase-functions🎯Skill

Streamlines Firebase Cloud Functions development with structured TypeScript patterns, error handling, and organized function implementations.

🎯
commit🎯Skill

Stages and commits git changes following specific Korean commit message guidelines for clean, meaningful version control.