All skills
amanktyr avatar

/testing

@1ee459a
by Aman Ktyramanktyr/tailor4 stars

Governs automated testing discipline, unit tests, integration tests, vitest, jest, pytest, mocking boundaries, regression tests, and truthful verification.

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

This session only. Nothing lands on disk.

SKILL.md

≈41 tokens always: the name and description. ≈906 when used: this file.

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. 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' });

Source: SKILL.md on GitHub

No alerts23d3 checks · Risk SAFE
  • Gen Agent Trust Hub23d

    This skill provides standard guidelines and best practices for automated testing across multiple programming languages. It defines procedural discipline for unit and integration testing without any detected malicious patterns or security risks.

  • Socket23d

    No alerts

  • Snyk23d

    Risk: LOW · No issues

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

Last checked against GitHub 3 weeks ago.

Activeupdated 4 weeks ago

README badge

README badge for amanktyr/tailor/testing