Frontend Typescript Testing logo

Frontend Typescript Testing

Community
shinpr
frontend-typescript-testing

リポジトリで設定済みのReactテスト・ブラウザハーネスを使用してフロントエンドテストを設計。RTL、MSW、Vitest、Playwrightが存在する場合に適用。コンポーネント、loading/error state、統合、フロントエンドE2Eテストの追加・レビュー時に使用。

Overview

Publishershinpr
Repositoryai-coding-project-boilerplate
Skill namefrontend-typescript-testing
Stars
234
Forks
28
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by shinpr on GitHub. Read the source before you install it.

Installation

Install the Frontend Typescript Testing AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/shinpr/ai-coding-project-boilerplate/tree/main/.claude/skills-ja/frontend-typescript-testing
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/shinpr/ai-coding-project-boilerplate.git /tmp/ai-coding-project-boilerplate
mkdir -p .claude/skills
cp -r /tmp/ai-coding-project-boilerplate/.claude/skills-ja/frontend-typescript-testing .claude/skills/frontend-typescript-testing
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Frontend Typescript Testing in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Frontend Typescript Testing on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Frontend Typescript Testing is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

TypeScript テストルール(フロントエンド)

前提条件の検出

フレームワークやコマンドを選択する前に、package.json、ロックファイル、テスト設定、既存テストのimportを確認する。Vitest、React Testing Library、MSW、Playwright固有のルールは、依存または設定が存在する場合にのみ適用する。異なるフレームワークが設定されている場合は、リポジトリの同等機能を使用する。実行可能なハーネスを特定できない場合は、作り出さずに、確認したpathと不足しているフレームワークまたはコマンドを報告する。

参照

テスト種別参照先用途
ユニット / 統合本ドキュメントRTL + Vitest + MSW での React コンポーネントテスト
E2Ereferences/e2e.mdPlaywright によるブラウザレベル E2E テスト

テストフレームワーク

  • Vitest: リポジトリ設定または既存テストで選択されている場合に使用
  • React Testing Library: コンポーネントテスト用
  • MSW (Mock Service Worker): APIモック用
  • テストのインポート: import { describe, it, expect, beforeEach, vi } from 'vitest'
  • コンポーネントテストのインポート: import { render, screen } from '@testing-library/react'
  • ユーザー操作: import userEvent from '@testing-library/user-event'
  • モックの作成: vi.mock() を使用

テストの基本方針

品質要件

  • リグレッション保護: クリティカルパスと再利用度の高いコンポーネントでは、明記された受け入れ結果、公開分岐、失敗状態を検証する
  • 独立性: 各テストは他のテストに依存せず実行可能
  • 再現性: 時刻、乱数、環境値、ネットワークレスポンス、ブラウザstateを制御し、同一の入力から同一の観測可能な結果を得る
  • 可読性: 各テストはユーザーから見える振る舞いを1つだけ名前で示し、setup・action・assertionを分け、その振る舞いで使用する値だけをfixtureに含める

テストの重点配分

複数の機能で再利用される共有コンポーネント、Custom hook、utilityは、リグレッションの影響範囲が広いため、公開分岐、error state、境界の契約を検証する。振る舞いが複数のrender済みユニットに依存するページ単位の構成は、統合/E2Eテストで検証する。

テストの種類と範囲

  1. 単体テスト(React Testing Library)

    • 個々のコンポーネントや関数の動作を検証
    • 外部依存はすべてモック化
    • ユーザーから観測可能な振る舞いに焦点を当てる
  2. 統合テスト(React Testing Library + MSW)

    • 複数のコンポーネントの連携を検証
    • MSW(Mock Service Worker)でAPIをモック
    • 実際のDB接続なし(DBはバックエンドが管理)
    • 主要な受け入れ基準を実装するフロー、または複数のrender済みコンポーネントが連携するフローを検証
  3. 機能横断検証

    • 新機能が共有の統合ポイントに及び、その失敗が主要なユーザージャーニーまたは契約を壊す、あるいは副次的な観測可能な振る舞いを劣化させる場合は、既存機能の継続性を証明義務とする。その失敗を露出できる最も安い境界で証明する
    • 検証パターン: 既存機能動作 → 新機能有効化 → 既存機能の継続性確認
    • 判定基準: 元の受け入れ基準で指定された表示内容とインタラクションの振る舞いを維持する。レンダリング時間のしきい値は、プロジェクト設定または要件で値と計測方法が定義されている場合にのみ適用する
    • CI/CDでの自動実行を前提とした設計

テストの実装規約

ディレクトリ構造と命名規則

  • コンポーネントのテストはそのコンポーネント自身のディレクトリに置き、実装とテストが一緒に移動する状態を保つ(Co-location原則)
  • テストファイル: {ComponentName}.test.tsx
  • 統合テストファイル: {FeatureName}.integration.test.tsx
  • テストスイート: 対象のコンポーネントや機能を説明する名前
  • テストケース: ユーザー視点から期待される動作を説明する名前

テストコードの品質ルール

コミットするテストはすべて有効に保つ。現行の振る舞いを保護するテストは修復する。テストを削除できるのは、対象の振る舞いが不要になったことを元の要件または実装契約で確認できる場合、または残す別のテストが、削除するテストが検出するリグレッションをすべて検出する場合である。

モックの型安全性の徹底

MSWハンドラーのresponse bodyは、それが代表するドメイン型に対して satisfies で制約する。契約から乖離したfixtureをコンパイル時に落とし、アプリが実際には受け取らない形に対してテストが通ってしまう状態を防ぐ。

コンポーネントや依存のモックには、テスト対象が実際に利用する範囲だけを型付けする(Pick<Props, 'usedProp'>、Pick<Router, 'push'>)。インターフェース全体は型付けせず、リテラルは satisfies で制約して余分なメンバーや誤った名前をコンパイル時に落とす。

テスト設計パターン

実装詳細ではなくユーザーから見える結果を検証する。クエリはユーザーが認識できるroleとaccessible name(getByRole/getByLabelText/getByText)で行い、getByTestId や container.querySelector に依存しない。操作は生のイベント発火ではなく、テストごとに userEvent.setup() した userEvent 経由で行い、ブラウザのイベント列を再現する。操作と非同期アサーションはすべて await する — awaitしない操作は更新前のrender結果に対してアサーションすることになるため、非同期UIは findBy* で待機する。

正常系だけでなく空・エラー・ローディング/非同期の状態も網羅する。error stateは共有ハンドラ集合を変更せず、そのテスト1件だけMSWハンドラを上書きして作る。

必要なUI state、accessible name、外部契約が不明な場合は、そのアサーションのテスト設計を止め、必要なUI Spec、受け入れ基準、実装契約、ユーザー判断を具体的に示す。期待する振る舞いを確認済みの独立したアサーションは継続する。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Frontend Typescript Testing AI skill do?

リポジトリで設定済みのReactテスト・ブラウザハーネスを使用してフロントエンドテストを設計。RTL、MSW、Vitest、Playwrightが存在する場合に適用。コンポーネント、loading/error state、統合、フロントエンドE2Eテストの追加・レビュー時に使用。

Why use Frontend Typescript Testing on TypingMind?

Because you install it once and use it with any model. Frontend Typescript Testing is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Frontend Typescript Testing in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/shinpr/ai-coding-project-boilerplate/tree/main/.claude/skills-ja/frontend-typescript-testing. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Frontend Typescript Testing?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Frontend Typescript Testing?

As many as you like. As long as a model supports skills, you can use Frontend Typescript Testing with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Frontend Typescript Testing AI skill free?

Yes. It is published on GitHub by shinpr under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇