All skills
jeffallan avatar

/test-master

@efebc44
by jeffallanjeffallan/claude-skills12k stars
1,124

Generates test files, creates mocking strategies, analyzes code coverage, designs test architectures, and produces test plans and defect reports across functional, performance, and security testing disciplines. Use when writing unit tests, integration tests, or E2E tests; creating test strategies or automation frameworks; analyzing coverage gaps; performance testing with k6 or Artillery; security testing with OWASP methods; debugging flaky tests; or working on QA, regression, test automation, quality gates, shift-left testing, or test maintenance.

Use this Skill: https://skilld.dev/gh/jeffallan/claude-skills/test-master

This session only. Nothing lands on disk.

referencesautomation-frameworks.md

≈1.9k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Automation Frameworks

Advanced Framework Patterns

Screenplay Pattern

// Better separation of concerns than POM
export class Actor {
  constructor(private page: Page) {}
  attemptsTo(...tasks: Task[]) {
    return Promise.all(tasks.map(t => t.performAs(this)));
  }
}

class Login implements Task {
  constructor(private email: string, private password: string) {}
  async performAs(actor: Actor) {
    await actor.page.getByLabel('Email').fill(this.email);
    await actor.page.getByLabel('Password').fill(this.password);
    await actor.page.getByRole('button', { name: 'Login' }).click();
  }
}

// Clear, maintainable test code
await new Actor(page).attemptsTo(new Login('user@test.com', 'pass'));

Keyword-Driven Testing

const keywords = {
  NAVIGATE: (page, url) => page.goto(url),
  CLICK: (page, selector) => page.click(selector),
  TYPE: (page, selector, text) => page.fill(selector, text),
  VERIFY: (page, selector) => expect(page.locator(selector)).toBeVisible(),
};

// Data drives execution - ideal for non-technical authors
const steps = [
  { keyword: 'NAVIGATE', args: ['/login'] },
  { keyword: 'TYPE', args: ['#email', 'user@test.com'] },
  { keyword: 'CLICK', args: ['#submit'] },
];

for (const step of steps) await keywords[step.keyword](page, ...step.args);

Model-Based Testing

// State machine defines valid transitions
const cartModel = {
  empty: { addItem: 'hasItems' },
  hasItems: { addItem: 'hasItems', removeItem: 'hasItems|empty', checkout: 'checkingOut' },
  checkingOut: { confirm: 'complete', cancel: 'hasItems' },
};

// Generate comprehensive test paths automatically
const testPaths = generatePathsFromModel(cartModel);

Maintenance Strategies

Self-Healing Locators

// Multi-strategy finder with automatic fallback
async function findElement(page: Page, strategies: string[]): Promise<Locator> {
  for (const selector of strategies) {
    const el = page.locator(selector);
    if (await el.count() > 0) return el;
  }
  throw new Error(`Not found: ${strategies.join(', ')}`);
}

// Usage: tries best -> good -> fallback
const submit = await findElement(page, [
  '[data-testid="submit"]',     // Best: stable test ID
  'button:has-text("Submit")',  // Good: semantic
  'button.primary',             // Fallback: CSS
]);

Error Recovery & Smart Retry

// Auto-retry with recovery actions
async function clickWithRecovery(page: Page, selector: string, retries = 3) {
  for (let i = 0; i < retries; i++) {
    try {
      await page.click(selector, { timeout: 5000 });
      return;
    } catch (e) {
      if (i === retries - 1) throw e;
      await page.reload();
      await page.waitForLoadState('networkidle');
    }
  }
}

// Exponential backoff for flaky operations
async function retryWithBackoff<T>(fn: () => Promise<T>, retries = 3): Promise<T> {
  for (let i = 0; i < retries; i++) {
    try {
      return await fn();
    } catch (e) {
      if (i === retries - 1) throw e;
      await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i)));
    }
  }
}

Scaling Strategies

Parallel & Distributed Execution

// playwright.config.ts
export default defineConfig({
  workers: process.env.CI ? 8 : 4,
  fullyParallel: true,
  retries: process.env.CI ? 2 : 0,
  
  // Shard tests across multiple machines
  shard: process.env.SHARD ? {
    current: parseInt(process.env.SHARD_INDEX),
    total: parseInt(process.env.SHARD_TOTAL),
  } : undefined,
});
# GitHub Actions: distribute across 5 workers
strategy:
  matrix:
    shard: [1, 2, 3, 4, 5]
steps:
  - run: npx playwright test --shard=${{ matrix.shard }}/5

Resource Optimization

// Reuse browser contexts for faster execution
let browser: Browser;
let context: BrowserContext;

test.beforeAll(async () => {
  browser = await chromium.launch();
  context = await browser.newContext();
});

test('test 1', async () => {
  const page = await context.newPage();
  // Test logic
  await page.close();
});

test.afterAll(async () => {
  await context.close();
  await browser.close();
});

CI/CD Integration

Complete Pipeline

name: E2E Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        shard: [1, 2, 3, 4]
    
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - run: npm ci
      - run: npx playwright install --with-deps
      
      - run: npx playwright test --shard=${{ matrix.shard }}/4
        env:
          CI: true
      
      - uses: actions/upload-artifact@v3
        if: always()
        with:
          name: report-${{ matrix.shard }}
          path: playwright-report/

Test Data Factories

export class UserFactory {
  static create(overrides?: Partial<User>): User {
    return {
      id: faker.string.uuid(),
      email: faker.internet.email(),
      name: faker.person.fullName(),
      role: 'user',
      ...overrides,
    };
  }

  static createMany(count: number) {
    return Array.from({ length: count }, () => this.create());
  }
}

// Seed test data
test.beforeEach(async ({ page }) => {
  await page.request.post('/api/test/seed', {
    data: { users: UserFactory.createMany(10) },
  });
});

Team Enablement

Training Program

**Week 1-2**: Framework basics, page objects, first test
**Week 3-4**: Data-driven, API integration, CI/CD
**Week 5-6**: Performance, error handling, scaling
**Ongoing**: Code reviews, knowledge sharing

Code Review Checklist

- [ ] Independent tests (no order dependency)
- [ ] Semantic locators (getByRole, getByLabel)
- [ ] Proper waits (no arbitrary timeouts)
- [ ] Error cases tested
- [ ] Test data cleanup
- [ ] Meaningful test names
- [ ] Page objects updated

Automation Strategy

ROI Calculation

const manual = { timePerRun: 30, runsPerSprint: 10 };
const automation = { development: 120, maintenance: 5 };

const timeSaved = (manual.timePerRun * manual.runsPerSprint) - automation.maintenance;
const breakEven = Math.ceil(automation.development / timeSaved);
const annualSavings = (timeSaved * 26 - automation.development) / 60; // hours

// Example: Break-even in 1 sprint, save 110 hours/year

Selection Criteria

**Automate**: Repetitive, stable UI, critical paths, data-driven, positive ROI
**Don't Automate**: Exploratory, changing UI, one-time, usability, negative ROI

Reporting & Metrics

Custom Reporter

class MetricsReporter implements Reporter {
  onTestEnd(test: TestCase, result: TestResult) {
    this.sendMetrics({
      name: test.title,
      duration: result.duration,
      status: result.status,
      retries: result.retry,
    });
  }
}

Quick Reference

Pattern Best For Complexity
Page Object Reusable components Medium
Screenplay Complex workflows High
Keyword-Driven Non-tech testers Low
Model-Based State machines High
Scaling Use Case
Parallel Reduce time
Distributed Large suites
Cloud Cross-browser
Resource Reuse Speed
Tool Category
Playwright, Cypress Web E2E
Appium, Detox Mobile
k6, Gatling Performance

Source: SKILL.md on GitHub

1 alert17d5 checks · Risk CRITICAL
  • Gen Agent Trust Hub17d

    The skill provides a comprehensive framework and reference guide for software testing, including unit, integration, and security testing. It involves processing user-provided code and API responses, which creates a surface for indirect prompt injection. Automated scanners flagged the documentation link and skill file, likely due to the inclusion of security testing payloads (e.g., SQL injection and XSS strings) used as diagnostic examples in the reference materials.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    1/11 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at efebc44. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 5 months ago
Other metadata
metadata
{
  "author": "https://github.com/Jeffallan",
  "version": "1.1.1",
  "domain": "quality",
  "triggers": "test, testing, QA, unit test, integration test, E2E, coverage, performance test, security test, regression, test strategy, test automation, test framework, quality metrics, defect, exploratory, usability, accessibility, localization, manual testing, shift-left, quality gate, flaky test, test maintenance",
  "role": "specialist",
  "scope": "testing",
  "output-format": "report",
  "related-skills": "fullstack-guardian, playwright-expert, devops-engineer, debugging-wizard, code-reviewer, feature-forge"
}
  • Testing
  • jest
  • vitest
  • pytest
  • test-automation
  • coverage
  • performance-testing
  • security-testing
  • e2e
  • quality-assurance

README badge

README badge for jeffallan/claude-skills/test-master

Generates test files, test strategies, and coverage analysis across unit, integration, E2E, performance, and security testing. Includes patterns for Jest, pytest, k6, and OWASP security testing, plus guidance on flaky test isolation, mock strategies, and test architecture design.

Generated from the current SKILL.md.

Does this skill cover performance and security testing, or just unit tests?
It covers functional, performance, and security testing. The skill includes reference guides for k6 and Artillery performance testing, OWASP security methods, and unit/integration/E2E test patterns.
What testing frameworks does this skill support?
It provides patterns for Jest, Vitest, pytest, and general E2E frameworks. The core workflow and assertions patterns are framework-agnostic; specific guidance is loaded from reference guides based on your tool choice.
Does this skill help debug flaky tests?
Yes. The core workflow includes a step to isolate flaky test failures by checking ordering dependencies, async handling, and adding stabilization logic or retries.
Can this skill generate test reports and defect documentation?
Yes. The skill outputs test plans with scope, test cases, coverage analysis, findings with severity ratings, and actionable fix recommendations.
Does this skill enforce mocking and isolation practices?
Yes. It requires mocking external dependencies, prohibits production data in tests, and forbids order-dependent tests. The skill enforces that each test runs independently.

Generated from the current SKILL.md. These answers refresh after source changes.