testing
TDD loops, Playwright automation, unit/integration/e2e, test pyramids.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- testing
- author
- Joshua (joshlcoleman), Hermes Agent
- license
- MIT
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "testing", "tdd", "playwright", "unit", "integration", "e2e" ], "related_skills": [ "test-driven-development", "frontend-react" ] } }
- platforms
- [ "linux", "macos", "windows" ]
- description
- TDD loops, Playwright automation, unit/integration/e2e, test pyramids.
02 资源文件 1
- 参考文档REPORT_GUIDE.md20.2 KB
03 SKILL.md 正文
Testing
When to Use
- Writing unit, integration, or e2e tests
- Setting up test infrastructure
- Test-driven development workflows
- Playwright browser automation
Quick Reference
| Type | Tool | When |
|---|---|---|
| Unit | Vitest/Jest | Pure functions, hooks |
| Integration | Testing Library | Component behavior |
| E2E | Playwright | Full user flows |
| API | Supertest/Vitest | API routes |
| Visual | Playwright/Chromium | Visual regression |
Test Pyramid
/ E2E \ ← Few (critical paths)
/ Integration \ ← Some (feature behavior)
/ Unit Tests \ ← Many (logic, edge cases)
/__________________\
Unit Testing (Vitest)
// useCounter.test.ts
import { renderHook, act } from '@testing-library/react';
import { useCounter } from './useCounter';
describe('useCounter', () => {
it('increments count', () => {
const { result } = renderHook(() => useCounter(0));
act(() => result.current.increment());
expect(result.current.count).toBe(1);
});
it('respects max value', () => {
const { result } = renderHook(() => useCounter(0, { max: 5 }));
for (let i = 0; i < 10; i++) act(() => result.current.increment());
expect(result.current.count).toBe(5);
});
});
Integration Testing (Testing Library)
// LoginForm.test.tsx
import { render, screen, userEvent } from '@testing-library/react';
import { LoginForm } from './LoginForm';
it('shows error on invalid email', async () => {
render(<LoginForm />);
const email = screen.getByLabelText(/email/i);
await userEvent.type(email, 'not-an-email');
await userEvent.click(screen.getByRole('button', { name: /submit/i }));
expect(screen.getByText(/invalid email/i)).toBeInTheDocument();
});
E2E Testing (Playwright)
// tests/auth.spec.ts
import { test, expect } from '@playwright/test';
test('user can log in', async ({ page }) => {
await page.goto('/login');
await page.fill('[name="email"]', 'test@example.com');
await page.fill('[name="password"]', 'password123');
await page.click('button[type="submit"]');
await expect(page).toHaveURL('/dashboard');
await expect(page.getByText('Welcome')).toBeVisible();
});
Playwright Config
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
reporter: [['html'], ['list']],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'mobile', use: { ...devices['iPhone 14'] } },
],
});
Pitfalls
- Testing implementation details → Test behavior, not internals
- Over-mocking → Use real dependencies when possible
- Flaky tests → Add proper waits, avoid
sleep - Missing error states → Test failure paths too
- No CI integration → Tests must run on every PR
Verification
- [ ] All tests pass locally
- [ ] Tests pass in CI
- [ ] Coverage ≥ 80% for critical paths
- [ ] No flaky tests (run 3x)
- [ ] E2E covers critical user flows
04 同仓库更多 Skills
security-audit
Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.
impeccable
Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks.
hallmark
Design skill for websites and new pages that look designed, not generated. Use when the user asks to build or design something new, or names Hallmark. Never use it on an existing design unless the user names Hallmark, as in `/hallmark redesign <path>`.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
appinsights-instrumentation
Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. USE FOR: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices. DO NOT USE FOR: adding App Insights to my app (use azure-prepare), add telemetry to my project (use azure-prepare), add monitoring (use azure-prepare). This skill provides guidance—azure-prepare orchestrates component changes.
youtube-automation
YouTube automation: upload, SEO, thumbnails, scheduling, analytics.