본문으로 건너뛰기
cccskills
무료GitHub에 공개

generate-tests

Use when asked to generate tests for a file, module or component, to raise coverage, or to bootstrap a suite for untested code. Detects the project's test framework and conventions first, then writes unit, integration and edge-case tests.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Playwright
설치 방법 보기

포함된 파일(1)

  • SKILL.md6.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Generate Tests — Comprehensive Test Suite Generator

Generate complete test coverage for any file, component, or module. Covers unit tests, integration tests, edge cases, error handling, and mocking — adapted to whatever testing framework the project uses.

Use when: you want tests generated for a file or component, need to improve test coverage, want edge case coverage, need mocks for external dependencies, or want to bootstrap a test suite for untested code.


When This Skill Is Activated

Follow every step below. Do NOT generate tests without first analyzing the project's testing setup and the target code.


Step 1: Detect the Testing Setup

Before writing any tests, discover the project's testing conventions:

  1. Find the test framework — Check package.json (dependencies/scripts), or config files:

    • jest.config.* / jest key in package.json → Jest
    • vitest.config.* → Vitest
    • cypress.config.* → Cypress
    • playwright.config.* → Playwright
    • pytest.ini / pyproject.toml [tool.pytest] → pytest
    • go.mod → Go testing
    • Cargo.toml → Rust (#[cfg(test)])
  2. Find existing test files — Search for *.test.*, *.spec.*, test_*.py, *_test.go to understand naming conventions and patterns already in use.

  3. Check for test utilities — Look for shared helpers, factories, custom matchers, or mock setups the project already provides (e.g., test/utils.ts, __mocks__/, conftest.py).

  4. Check the test script — Read the test script in package.json (or equivalent) to understand how tests are run, what flags are used, and what coverage tool is configured.

Match the project's existing conventions exactly. File naming, import style, assertion style, describe/it vs test, etc.


Step 2: Analyze the Target Code

Read the file or component the user wants tested. Identify:

  • All exported functions, classes, methods, and components
  • Input types and return types (or infer them)
  • External dependencies (API calls, database, file system, third-party libs)
  • Side effects (mutations, network calls, timers, DOM manipulation)
  • Error paths (throw statements, catch blocks, error returns)
  • Edge cases (null/undefined inputs, empty arrays, boundary values, large inputs)
  • Async behavior (promises, callbacks, streams)

Step 3: Plan the Test Suite

Before writing code, outline what you'll test:

Unit Tests

  • Every exported function with representative inputs
  • Return values for happy path
  • Error handling for invalid inputs
  • Boundary values (0, -1, empty string, null, max int, etc.)
  • Type coercion edge cases if applicable

Integration Tests (if the code interacts with other modules)

  • Component interactions and data flow
  • API calls with mocked responses (success + failure)
  • Service layer with mocked dependencies
  • State management side effects

Edge Cases and Error Handling

  • Null, undefined, empty inputs
  • Malformed data
  • Network failures / timeouts
  • Concurrent access / race conditions
  • Extremely large inputs

Step 4: Write the Tests

Follow these principles:

Structure

describe("[ModuleName]", () => {
  describe("[functionName]", () => {
    it("should [expected behavior] when [condition]", () => {
      // Arrange
      // Act
      // Assert
    });
  });
});
  • Descriptive test names — Read like documentation: "should return empty array when input is null"
  • AAA pattern — Arrange (setup), Act (execute), Assert (verify). Separate each visually.
  • One assertion per concept — Multiple expect() calls are fine if they assert one logical thing
  • Group with describe — One block per function/method/component behavior
  • Setup/teardown — Use beforeEach/afterEach for test isolation. Clean up subscriptions, timers, mocks.

Mocking Strategy

  • Mock external dependencies only — Don't mock the code under test
  • Use the project's existing mock patterns (e.g., jest.mock(), vi.mock(), unittest.mock)
  • Create test data factories for complex objects instead of inline literals
  • Mock timers (jest.useFakeTimers() / vi.useFakeTimers()) for time-dependent code
  • Mock dates for deterministic snapshots
  • Always restore mocks in afterEach to prevent test pollution

Async Testing

  • Always await async functions or return the promise
  • Test both resolve and reject paths
  • Use waitFor / findBy for async UI updates (React Testing Library)
  • Test loading, success, and error states

Framework-Specific Guidance

FrameworkComponent TestingKey Patterns
ReactReact Testing Libraryrender(), screen.getByRole(), userEvent, waitFor
VueVue Test Utilsmount(), shallowMount(), wrapper.find(), trigger()
AngularTestBedTestBed.configureTestingModule(), fixture.detectChanges()
Node.jsSupertestrequest(app).get("/api/...").expect(200)
Pythonpytest@pytest.fixture, monkeypatch, parametrize
Gotestingt.Run(), table-driven tests, t.Parallel()

Step 5: Verify and Improve

After generating the tests:

  1. Run the tests — Execute the test suite to make sure they pass
  2. Check coverage — Identify untested lines or branches
  3. Add missing cases — Fill gaps in coverage, especially error paths
  4. Review test quality — Tests should fail when the code breaks, not just when the tests break

Coverage Goals

PriorityCoverage Target
Critical business logic90%+
Utility functions85%+
UI components80%+
Configuration/glue code60%+

Focus on branch coverage over line coverage — untested else and catch paths are where bugs hide.


Output Checklist

Before finishing, verify:

  • Tests follow the project's existing naming convention and file location
  • All exported functions/components have at least one test
  • Happy path tested for every function
  • Error/failure path tested for every function that can fail
  • Edge cases covered (null, empty, boundary values)
  • External dependencies are mocked (no real API calls, no real DB)
  • Async code is properly awaited
  • Mocks are cleaned up in afterEach
  • Tests are independent — can run in any order
  • Test names read like documentation

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Train and optimize AI agents using Microsoft's Agent Lightning framework with reinforcement learning. Use when setting up agent training, instrumenting agents with tracing, configuring LightningStore, implementing reward functions, or optimizing prompts with RL/APO algorithms.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

coco-research/coco7602026년 10월 19일 업데이트

Post-run self-evaluation system that scores agent output on correctness, clarity, actionability, and conciseness. Use after /team runs, skill executions, or when explicitly asked to evaluate output quality.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

coco-research/coco7602026년 10월 19일 업데이트

Create AI marketing videos for ads, promos, product launches, and brand content. Models: Veo, Seedance, Wan, FLUX for visuals, Kokoro for voiceover. Types: product demos, testimonials, explainers, social ads, brand videos. Use for: Facebook ads, YouTube ads, product launches, brand awareness. Triggers: marketing video, ad video, promo video, commercial, brand video, product video, explainer video, ad creative, video ad, facebook ad video, youtube ad, instagram ad, tiktok ad, promotional video, launch video

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

coco-research/coco7602026년 10월 19일 업데이트

Use when building AI features into a product: LLM integration, RAG pipelines, guardrails, streaming, AI UX, prompt engineering, or AI cost control. Treats prompts as code and validates every model output.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

coco-research/coco7602026년 10월 19일 업데이트

Your AI research and engineering brain trust. 59 named personas across 8 cells covering frontier labs, applied product, model architecture, reasoning/RL/agents, alignment and interpretability, theory and science of DL, multimodal and…

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

coco-research/coco7602026년 10월 19일 업데이트

Use when designing a new REST or GraphQL API, reviewing an API spec before implementation, setting team API standards, or migrating REST to GraphQL. Covers resources, HTTP semantics, pagination, error handling, and pitfalls.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

coco-research/coco7602026년 10월 19일 업데이트

coco-research의 스킬 모두 보기

이 스킬의 문제 신고