スキル一覧に戻る
Spectaculous-Code

test-writer

by Spectaculous-Code

0🍴 0📅 2026年1月25日
GitHubで見るManusで実行

SKILL.md


name: test-writer description: | Create and maintain tests for the Raamattu Nyt monorepo using Vitest and React Testing Library.

Use when:

  • Writing new tests for hooks, components, or utility functions
  • Analyzing recent git commits to identify code needing tests
  • Reviewing existing tests for correctness and coverage
  • Creating mocks for Supabase, auth, or other dependencies
  • Debugging test failures or flaky tests

Triggers: "write tests", "test this", "add tests", "need tests for", "analyze test coverage", "fix failing tests", "mock this", "review tests"

Test Writer

Write and maintain tests for the Raamattu Nyt monorepo.

Context Files (Read First)

For structure and conventions, read from Docs/context/:

  • Docs/context/repo-structure.md - Where test files go
  • Docs/context/conventions.md - Naming patterns

Quick Start

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run specific test file
npx vitest run path/to/file.test.ts

Test File Conventions

  • Place tests adjacent to source: useHook.tsuseHook.test.ts
  • Use .test.ts for pure logic, .test.tsx for React components/hooks
  • Name: describe("ComponentName") or describe("hookName")

Standard Test Structure

import { describe, expect, it, vi, beforeEach } from "vitest";

// Mocks BEFORE imports (hoisted)
vi.mock("@/integrations/supabase/client", () => ({
  supabase: { rpc: vi.fn() }
}));

// Import module under test AFTER mocks
import { myFunction } from "./myModule";

describe("myFunction", () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it("does expected behavior", () => {
    expect(myFunction()).toBe(expected);
  });
});

Hook Testing Pattern

import { renderHook, waitFor } from "@testing-library/react";

// Wrapper for context providers
const wrapper = ({ children }) => (
  <AuthProvider>{children}</AuthProvider>
);

it("returns initial state", () => {
  const { result } = renderHook(() => useMyHook(), { wrapper });
  expect(result.current.loading).toBe(true);
});

it("updates on async action", async () => {
  const { result } = renderHook(() => useMyHook(), { wrapper });
  await waitFor(() => {
    expect(result.current.data).toBeDefined();
  });
});

Common Mocks

See references/mocks.md for reusable mock patterns:

  • Supabase client (RPC, auth, schema queries)
  • useAuth hook
  • React Query
  • localStorage

Workflow

  1. Identify what to test

    • Use code-wizard skill to find the file/function
    • Check git log for recent changes: git log --oneline -20
  2. Check existing tests

    • Find tests: Glob pattern: **/*.test.{ts,tsx}
    • Read related test files for patterns
  3. Write tests covering

    • Happy path (normal operation)
    • Error cases (API failures, invalid input)
    • Edge cases (empty arrays, null, undefined)
    • Loading states for async operations
  4. Run and verify

    npx vitest run path/to/file.test.ts
    

Test Quality Checklist

  • Tests are independent (no shared state between tests)
  • Mocks are cleared in beforeEach
  • Async operations use waitFor not arbitrary delays
  • Error scenarios are tested
  • Edge cases covered (null, empty, boundary values)
SituationDelegate To
Find code to testcode-wizard
Debug test failuressystematic-debugging
CI test failuresci-doctor
Lint errors in testslint-fixer

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です