Index of every page on this site: llms.txt
All skills
amanktyr avatar

/testing

@5711aad
by Aman Ktyramanktyr/tailor6 stars
Run it yourself

Governs automated testing discipline, unit tests, integration tests, vitest, jest, pytest, mocking boundaries, anti-flakiness, behavioral assertions, regression tests, and truthful verification.

Use this Skill: https://skilld.dev/gh/amanktyr/tailor/testing

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈51 tokens for metadata: the name and description. ≈1.4k when used: this file.

Description uses 2.5% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈204 characters, or 2.5%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Testing Discipline Skill

Activate this skill when creating features, fixing bugs, refactoring code, or running verification test suites.

Testing Law: Untested code is broken code. Flaky tests are liabilities. Verified code has exit code 0.


1. Targeted Test Execution Matrix

Run targeted tests for modified files to provide fast feedback, then run the full suite before concluding:

Stack / Tool Targeted Single-File Test Command Full Project Test Suite Command
Node.js (Vitest) npm test -- path/to/file.test.ts npm test
Node.js (Jest) npx jest path/to/file.test.ts npm test
Python (Pytest) pytest tests/test_file.py -k "test_name" pytest
Django python manage.py test app.tests.TestClass python manage.py test
Go go test -v ./pkg/service -run TestFunctionName go test ./...
Rust cargo test test_name cargo test
.NET C# dotnet test --filter "FullyQualifiedName~TestMethod" dotnet test
PHP (PHPUnit) vendor/bin/phpunit tests/UserTest.php vendor/bin/phpunit

2. The Testing Pyramid & Mocking Boundaries

      /\
     /  \     E2E Tests (Crucial user journeys only)
    /────\
   /      \   Integration Tests (API routes + DB queries + contracts)
  /────────\
 /          \ Unit Tests (Pure domain logic, utilities, edge cases)
/────────────\

Mocking Rules

  • Mock External Boundaries Only: Mock third-party payment gateways, email delivery, and cloud storage.
  • Do NOT Mock Pure Logic: Never mock internal business functions or data transformers; test them with real inputs and assert exact outputs.
  • Use Deterministic Factories: Use factories with fixed seeds; avoid random numbers (Math.random()) or unpinned system clocks in test assertions.

3. Non-Negotiable Testing Invariants

  1. Zero Fabrication: Never state "All tests passed" without executing the test command and confirming that the process exited with code 0.
  2. Regression Assertion for Bugfixes: Every bug fix must include an automated regression test reproducing the original bug condition and asserting its resolution.
  3. Clean Teardown: Ensure tests clean up temporary files, mock servers, and database records to prevent cross-test pollution.

4. Testing Execution Workflow & Mocking Contrasts

Step-by-Step Testing Protocol

  1. Runner Discovery: Identify the project test runner from package.json or stack manifests (vitest, jest, pytest, go test).
  2. Reproduction / Contract Test: Before fixing a bug, create a minimal test case asserting the failing condition. Before adding a feature, write tests defining the acceptance criteria.
  3. Targeted Execution: Run the test targeting only the modified test file (npm test -- path/to/spec.test.ts).
  4. Full Verification: Run the full project test suite (npm test) and confirm exit code 0 before concluding.

Mocking Contrast Matrix

// ❌ WRONG: Mocking internal pure business functions (tests nothing meaningful)
vi.spyOn(userService, 'calculateDiscount').mockReturnValue(10);
// Tests become brittle and assert implementation details rather than real behavior!
// ✅ CORRECT: Test pure logic with real inputs, mock ONLY external I/O
// Test pure logic directly:
expect(calculateDiscount({ userTier: 'GOLD', cartTotal: 100 })).toBe(10);

// Mock external network/payment gateway only:
vi.spyOn(stripeClient.charges, 'create').mockResolvedValue({ id: 'ch_test123', status: 'succeeded' });

5. Anti-Flakiness Invariants & Behavioral Test Standards

A. Zero Arbitrary Sleeps / Hardcoded Delays

  • Flaky Anti-Pattern:
    // ❌ BRITTLE: Hardcoded sleep fails on busy CI runners and wastes seconds locally
    await new Promise((r) => setTimeout(r, 1000));
    expect(queryStatus()).toBe('COMPLETED');
  • Robust Standard (Deterministic Polling):
    // ✅ ROBUST: Resolves as soon as the condition is satisfied
    await vi.waitFor(() => {
      expect(queryStatus()).toBe('COMPLETED');
    }, { timeout: 2000, interval: 50 });

B. Test User-Visible Behavior, Not Implementation Details

  • Brittle Anti-Pattern: Querying by internal CSS classes (container.querySelector('.btn-primary-blue-400')) or inspecting private component state.
  • Robust Standard: Query by accessible ARIA roles, labels, or test IDs:
    // ✅ ROBUST: Resilient to CSS refactors and verifies real accessibility
    const submitBtn = screen.getByRole('button', { name: /save changes/i });
    expect(submitBtn).toBeEnabled();

C. Deterministic Time & Clocks

  • Never write tests that depend on the current real-world clock (new Date()).
  • Use fake timers (vi.useFakeTimers(), vi.setSystemTime(new Date('2026-01-01'))) for time-dependent operations.

6. Pre-Commit Testing Checklist

Before marking any task complete:

  • Targeted Verification: Executed targeted test command for the modified file with exit code 0.
  • Full Suite Verification: Executed npm test (or ecosystem equivalent) with exit code 0.
  • Zero Arbitrary Sleeps: Verified tests use waitFor() instead of setTimeout().
  • Behavioral Assertions: Asserted public contracts or accessible roles, not private methods or CSS classes.
  • Clean State Isolation: Verified tests do not leak database records or global mocks.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts27d3 checks · Risk SAFE
  • Gen Agent Trust Hub27d

    The skill provides a comprehensive set of guidelines and best practices for automated testing across various programming languages. It outlines standard test execution commands, mocking strategies, and anti-flakiness patterns. No security risks, obfuscation, or malicious instructions were detected.

  • Socket27d

    No alerts

  • Snyk27d

    Risk: LOW · No issues

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

Last checked against GitHub last month.

Steadyupdated last month

README badge

README badge for amanktyr/tailor/testing