Skip to main content
ClaudeWave
Skill58 repo starsupdated 2mo ago

testing-workflow

Generates test plans, writes unit/integration/E2E test files, identifies coverage gaps, flags common testing anti-patterns. Use when writing tests, creating test suites, planning test strategies, mocking dependencies, measuring code coverage, or test planning.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/monkilabs/opencastle /tmp/testing-workflow && cp -r /tmp/testing-workflow/src/orchestrator/skills/testing-workflow ~/.claude/skills/testing-workflow
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Testing Workflow

## Workflow

1. **Plan** — Write a test plan using the Pre-Implementation categories below.
2. **Implement** — Write unit/integration tests; run and verify passing.
3. **E2E** — Run E2E tests in browser via the **e2e-testing** capability slot.
4. **Validate** — Run the Post-Implementation Checklist.
5. **Fix loop** — If any step fails → fix → re-run from step 2.

## Core Rules

- Validate every feature: happy paths, edge cases, error conditions, interactions.
- **Mandatory**: Test in browser via **e2e-testing** capability slot before marking complete.

## E2E Context Limits

| Rule | Detail |
|------|--------|
| One suite per session | Never run all suites in one conversation |
| Max 3 screenshots | Per session |
| `evaluate_script()` over `take_snapshot()` | Returns less data |
| Reload between flows | Clears state |
| Log results | Append to `.opencastle/logs/e2e-results.md` |

Suite files: see `.opencastle/project.instructions.md`.

## Pre-Implementation Test Plan

| Category | What to cover |
|----------|---------------|
| Initial state | Page loads with defaults; components in expected state |
| User interactions | Buttons, dropdowns, filters (URL params + refetch), form validation |
| State transitions | Filter changes produce different results; loading states; backend sync |
| Edge cases | Empty results, min/max boundaries, invalid input, network errors |
| Integration | Data flow server→UI, URL params↔state, server vs client filtering |
| Responsive (MANDATORY for UI) | All breakpoints per **browser-testing** skill / **validation-gates** Gate 3 |

## Coverage Requirements

| Layer | Minimum |
|-------|---------|
| Unit (functions, components, hooks) | 95% |
| Integration (boundaries, URL sync) | All boundaries |
| E2E (journeys, interactions, errors) | All critical paths |

## Anti-Patterns

| Anti-Pattern | Correct Approach |
|---|---|
| Testing only initial page load | Test filter changes, different results |
| Assuming filters work because they render | Verify each option changes results |
| Client-side only | Verify server requests are triggered |
| Single scenario | Test urban, rural, edge, out-of-range |
| Visual inspection only | Verify data values programmatically |

## Post-Implementation Checklist

- [ ] Dev server running; app opened in browser
- [ ] All interactive elements tested
- [ ] Data changes verified (not just visual)
- [ ] Edge cases: empty states, max/min values, errors
- [ ] All project-defined responsive breakpoints checked (no overflow/breakage)
- [ ] URL parameters correct
- [ ] Screenshots taken of key scenarios

## Commands

```sh
# Unit / integration
npx vitest run --coverage          # all tests + coverage
npx vitest run src/utils.test.ts   # single file

# E2E (Playwright)
npx playwright test                # all E2E suites
npx playwright test --ui           # interactive mode
```

```ts
// Unit test with mock
import { describe, it, expect, vi } from 'vitest';
import { fetchItems } from './api';

describe('fetchItems', () => {
  it('returns filtered results', async () => {
    vi.spyOn(global, 'fetch').mockResolvedValue(
      new Response(JSON.stringify([{ id: 1, name: 'test' }]))
    );
    const items = await fetchItems({ category: 'active' });
    expect(items).toHaveLength(1);
    expect(fetch).toHaveBeenCalledWith(expect.stringContaining('category=active'));
  });
});
```

```ts
// E2E test (Playwright)
import { test, expect } from '@playwright/test';

test('filter updates results and URL', async ({ page }) => {
  await page.goto('/items');
  await page.getByRole('combobox', { name: 'Category' }).selectOption('active');
  await expect(page).toHaveURL(/category=active/);
  await expect(page.getByRole('listitem')).not.toHaveCount(0);
});
```

## References

| Resource | Purpose |
|----------|--------|
| **browser-testing** skill | Chrome DevTools automation for E2E |
| **validation-gates** Gate 3 | Responsive breakpoint checks |
| `project.instructions.md` | Suite files, project-specific test config |
astro-frameworkSkill

Creates pages/layouts, defines content collections, configures hydration directives, and wires integrations. Use when adding or modifying Astro pages, layouts, components, or content collections. Trigger terms: Astro, content collection, client:load, client:visible, astro:content

browser-testingSkill

Drive real browsers via Chrome DevTools MCP: navigate pages, capture snapshots, run responsive checks, and collect console/perf traces. Use when the user mentions: 'validate UI change in Chrome', 'capture a screenshot', 'run responsive checks', or 'collect console logs'. Trigger terms: browser testing, DevTools, console logs, screenshot, responsive testing

cloudflare-platformSkill

Creates and deploys Cloudflare Workers, configures wrangler.toml bindings, sets up KV/D1/R2 storage and Durable Objects, manages Pages deployments, and implements edge function patterns. Use when building or deploying Cloudflare Workers, setting up Pages, working with KV/D1/R2 storage, configuring wrangler.toml, or deploying edge applications.

contentful-cmsSkill

Creates Contentful content types, queries entries via GraphQL/REST, runs CLI migrations, and manages assets and locales. Use when building or modifying Contentful content models, writing queries, or migrating content.

convex-databaseSkill

Convex reactive database patterns, schema design, real-time queries, mutations, actions, authentication, migrations, performance optimization, and component creation. Use when designing Convex schemas, writing queries/mutations, managing the Convex backend, setting up auth, migrating data, optimizing performance, or building Convex components.

coolify-deploymentSkill

Deploys applications, databases, and services on self-hosted Coolify instances, manages environments and env vars, runs infrastructure diagnostics, and performs batch operations. Use when deploying apps to Coolify, managing Coolify servers, debugging deployment issues, setting up databases, or managing Coolify infrastructure.

cypress-testingSkill

Writes Cypress E2E/component tests, configures `cy.intercept()` and `cy.session()`, authors custom commands, and wires CI artifacts. Use when creating E2E specs, component tests, or CI test pipelines. Trigger terms: cypress, e2e, component test, cy.intercept, cy.session

drizzle-ormSkill

Drizzle ORM schema definition, type-safe queries, relational queries, CRUD operations, transactions, migrations with drizzle-kit, and database setup for PostgreSQL, MySQL, and SQLite. Use when defining database schemas, writing queries or joins, managing migrations, setting up a new Drizzle project, or working with drizzle-kit.