mcpField
W
writing-tests

writing-tests

github.com/augmntTesting & quality249 installsUpdated 40w ago
Repository

About writing-tests

writing-tests is a testing skill for developers that helps choose test types and organize coverage around user-visible behavior and risk. It includes query and test-structure guidance, plus pointers to mocking and coverage details.

Key features

  1. 01Risk-based test prioritization
  2. 02Unit, integration, and E2E guidance
  3. 03Arrange-Act-Assert pattern
  4. 04Accessible query selection
  5. 05Colocated test file layout
  6. 06Minimum viable testing guidance

Use cases

  1. 01Choosing test types for a feature
  2. 02Prioritizing authentication and checkout tests
  3. 03Testing behavior in UI components
  4. 04Planning tests when time is limited

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/augmnt/webdev-skills --skill writing-tests

After installing, type/writing-testsin Claude Code to confirm it loaded.

Bundled filesMOCKING.md

Details

From the project README

Writing Tests

Test behavior, not implementation. Prioritize by risk.

When to Use Each Type

TypeWhatWhenTools
UnitSingle function/hookPure logic, calculationsVitest, Jest
IntegrationComponent + depsForms, data displayTesting Library
E2EFull user flowCritical pathsPlaywright

Always Test

  • Auth flows
  • Payment/checkout
  • Data mutations (create, update, delete)
  • Authorization rules
  • Critical business logic

Rarely Test

  • Static content
  • Third-party internals
  • Pure styling

File Organization

src/components/Button/
├── Button.tsx
└── Button.test.tsx      # Colocated

e2e/                     # E2E at root
├── auth.spec.ts
└── checkout.spec.ts

Patterns

Arrange-Act-Assert
test('increments on click', () => {
  // Arrange
  render(<Counter initial={0} />)
  // Act
  fireEvent.click(screen.getByRole('button'))
  // Assert
  expect(screen.getByText('1')).toBeInTheDocument()
})
Query Priority (best → worst)
  1. getByRole - semantic, accessible
  2. getByLabelText - form inputs
  3. getByText - content
  4. getByTestId - last resort
Test Behavior, Not Implementation
// ❌ Implementation
expect(component.state.isOpen).toBe(true)

// ✅ Behavior
expect(screen.getByRole('dialog')).toBeVisible()

Minimum Viable Testing

If time-constrained:

  1. E2E for happy paths (covers most ground)
  2. Unit for complex logic (catches edge cases)
  3. Integration for critical components (forms, data)

Advanced Patterns

For API mocking, test fixtures, and coverage guidance, see MOCKING.md.

Comments

Markdown supported