- name
SKILL.md
技能檔案保留在發布者的儲存庫中。
在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-testing -a cursor -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-testing -a claude-code -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-testing -a codex -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add shinpr/ai-coding-project-boilerplate --skill frontend-typescript-testing -a grok -y在 Grok Bot 聊天中傳送複製的訊息。Bot 會從 GitHub 取得這個 SKILL.md,並加入你所有 Bot 共用的技能中。
Install this skill: https://github.com/shinpr/ai-coding-project-boilerplate/tree/HEAD/.claude/skills-en/frontend-typescript-testing來自發布者
Inspect package.json, the lockfile, test configuration, and existing test imports before selecting a framework or command. Apply Vitest, React Testing Library, MSW, or Playwright rules only when the dependency/configuration is present. Use the repository's configured equivalent when different. If no runnable harness can be identified, report the inspected paths and the missing framework or command instead of inventing one.
import { describe, it, expect, beforeEach, vi } from 'vitest'import { render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'vi.mock()For shared components, custom hooks, and utilities reused across features, cover their public branches, error states, and boundary contracts because their regression blast radius is wider. Verify page-level composition through integration/E2E tests when the behavior depends on multiple rendered units.
Unit Tests (React Testing Library)
Integration Tests (React Testing Library + MSW)
Cross-functional Verification
{ComponentName}.test.tsx{FeatureName}.integration.test.tsxKeep every committed test active. Repair a test that protects current behavior. Remove a test when its behavior is no longer required and the source requirement or implementation contract confirms the removal, or when another retained test fails for every regression the removed test detects.
Constrain an MSW handler's response body with satisfies against the domain type it stands for, so a fixture that drifts from the contract fails at compile time rather than producing a passing test against a shape the app never receives.
Type a component or dependency mock to the surface the subject under test actually consumes — Pick<Props, 'usedProp'>, Pick<Router, 'push'> — rather than the full interface, and constrain the literal with satisfies so an extra or misnamed member fails at compile time.
Test user-visible results, not implementation details. Query by the role and accessible name the user perceives (getByRole/getByLabelText/getByText), not getByTestId or container.querySelector. Drive interactions through userEvent with userEvent.setup() per test rather than firing raw events, so the test reproduces the browser's event sequence. await every interaction and async assertion — an unawaited interaction asserts against the pre-update render, so use findBy* for async UI.
Cover the empty, error, and loading/async states that the component renders or the accepted behavior defines, not only the happy path. Produce an error state by overriding the MSW handler for that single test rather than changing the shared handler set.
When the required UI state, accessibility name, or external contract is unknown, stop test design for that assertion and name the UI Spec, acceptance criterion, implementation contract, or user decision needed. Continue with independent assertions whose expected behavior is observed.
Designs frontend tests using the repository's configured React test and browser harnesses, including RTL, MSW, Vitest, and Playwright when present. Use when adding or reviewing component, loading/erro
---name: frontend-typescript-testingdescription: Designs frontend tests using the repository's configured React test and browser harnesses, including RTL, MSW…---# .claude/skills-en/frontend-typescript-testing/SKILL.md總覽
Designs frontend tests using the repository's configured React test and browser harnesses, including RTL, MSW, Vitest, and Playwright when present. Use when adding or reviewing component, loading/error-state, integration, or frontend E2E tests.
常見問題
從發布者下載 .claude/skills-en/frontend-typescript-testing/SKILL.md,或複製路徑後開啟儲存庫。PlugMCP 只收錄這項技能,不代管檔案。
發布者將它存放在 https://github.com/shinpr/ai-coding-project-boilerplate。
Claude、Cursor、Codex 和 Grok Build 可以讀取你從發布者儲存庫加入的 SKILL.md。在聊天中傳送技能的 GitHub 資料夾連結,Grok Bot 就會安裝它。