Get the FREE Ultimate OpenClaw Setup Guide →

qa

Scanned
npx machina-cli add skill Joncik91/ucai/qa --openclaw
Files (1)
SKILL.md
4.3 KB

QA Engineer

Testing patterns, test design, coverage strategy, and quality automation for any language or framework.


Step 1: Detect the Stack

Before writing tests, identify the language, framework, and test tooling:

SignalTest framework likely in use
vitest.config.* or vitest in package.jsonVitest
jest.config.* or jest in package.jsonJest
playwright.config.*Playwright (E2E)
cypress.config.*Cypress (E2E)
pytest.ini / pyproject.toml [tool.pytest.*]pytest
*_test.go filesGo test
*_spec.rb / spec/ dirRSpec
*.test.cs / xunit.runner.jsonxUnit / NUnit
*.spec.ts with AngularJasmine + Karma or Jest

Check: cat package.json, ls -la, cat pytest.ini — whichever applies. Also check existing test files to understand conventions.


Step 2: Research Current Practices

Search for current testing patterns for the detected stack:

WebSearch: "<framework> unit testing best practices 2025"
WebSearch: "<test library> mocking patterns 2025"
WebSearch: "Playwright E2E testing patterns 2025"
WebSearch: "<framework> test coverage strategy 2025"

Step 3: Universal Testing Principles

These apply regardless of language or test framework.

Test Pyramid

  • Unit tests (70%): fast, isolated, test one thing; mock all dependencies
  • Integration tests (20%): test that components work together; use real dependencies where practical
  • E2E tests (10%): test critical user journeys against a real browser/API; keep them minimal and stable

Test Isolation

  • Each test is independent — no shared mutable state between tests
  • Tests can run in any order and produce the same result
  • Clean up after each test (reset DB, clear mocks, restore spies)
  • Never depend on test execution order

Naming Conventions

Use a consistent naming pattern that reads as documentation:

<unit>_<condition>_<expected result>

// OR

describe("UserService") {
  describe("createUser") {
    it("returns 409 when email already exists")
    it("hashes password before storing")
    it("sends welcome email on success")
  }
}

What to Test

  • Happy path: the normal, expected flow works
  • Edge cases: empty input, max length, boundary values, null/undefined
  • Error paths: what happens when a dependency fails, input is invalid, or permissions are denied
  • State transitions: document the before/after state change
  • Don't test implementation details — test observable behavior

Mocking Strategy

  • Mock at the boundary (I/O, network, time, randomness) — not inside your own code
  • Prefer fakes (in-memory implementations) over mocks for complex dependencies
  • Use spies to verify side effects, not to control return values
  • Reset all mocks between tests

Coverage

  • Coverage measures what code was executed, not what was verified — don't optimize for the number
  • Target: 80%+ line coverage as a floor, not a ceiling
  • Prioritize coverage of: auth paths, payment flows, data mutations, error handling
  • Untested code that matters > high coverage of trivial code

Async Testing

  • Always await async operations in tests — never fire-and-forget
  • Use explicit timeouts for timing-sensitive tests; prefer polling over fixed waits
  • For E2E: use waitForSelector / waitForResponse — never sleep()

Flaky Test Prevention

  • Never use sleep() / fixed delays — wait for conditions
  • Avoid time-dependent assertions — mock the clock
  • Isolate external services — use test doubles, not real APIs
  • Clean up test data after each run

Review Checklist

Before any test PR:

  • Tests are isolated — no shared mutable state
  • Each test has one clear assertion or outcome
  • Test names describe behavior, not implementation
  • No sleep() / fixed delays
  • Mocks reset between tests
  • Error paths tested alongside happy paths
  • Async operations properly awaited
  • Tests pass in isolation and as a suite
  • Coverage added for new code paths
  • No test skipped without explanation

Source

git clone https://github.com/Joncik91/ucai/blob/main/skills/qa/SKILL.mdView on GitHub

Overview

QA Engineer covers test design, coverage strategy, and quality automation for any language or framework. It guides stack detection, pattern selection, and workflow improvements to raise test quality.

How This Skill Works

First detect the stack by inspecting config files and existing tests. Then apply universal testing principles (pyramid, isolation, naming, mocks) to shape a balanced test suite. It returns concrete, stack-specific steps to improve test quality and coverage.

When to Use It

  • You need to generate or write unit tests for a new or existing codebase.
  • You want to analyze current test coverage and identify gaps.
  • You are scaffolding E2E tests with Playwright or Cypress.
  • You need to configure Jest, Vitest, or similar tooling and enforce standards.
  • You aim to implement robust testing patterns and improve overall test quality.

Quick Start

  1. Step 1: Detect the stack by inspecting config files (e.g., vitest.config.* or playwright.config.*) and existing tests.
  2. Step 2: Choose a testing approach per layer and scaffold initial tests with consistent naming.
  3. Step 3: Run tests, review coverage, and iterate to improve reliability and reduce flakiness.

Best Practices

  • Follow the Test Pyramid: 70% unit, 20% integration, 10% E2E.
  • Ensure test isolation: tests do not share state or rely on execution order.
  • Use consistent, doc-like naming patterns for tests.
  • Test observable behavior, not internal implementation details.
  • Mock at boundaries, prefer fakes when possible, and reset mocks between tests.

Example Use Cases

  • Write unit tests for a UserService to validate input handling and error paths.
  • Add integration tests for the data layer with in-memory stubs.
  • Scaffold Playwright E2E tests for the login flow with waitForSelector.
  • Configure Jest/Vitest with a coverage threshold and clear mocks.
  • Refactor flaky tests by removing sleeps and stabilizing timers.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers