home / skills / tlabs-xyz / tbtc-v2-performance / testing-test-writing

testing-test-writing skill

/.claude/skills/testing-test-writing

This skill guides you to write focused, fast, behavior-driven tests for core flows using Jest, Vitest, PyTest, or similar.

npx playbooks add skill tlabs-xyz/tbtc-v2-performance --skill testing-test-writing

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.0 KB
---
name: Testing Test Writing
description: Write strategic, minimal tests focused on core user flows and critical paths, testing behavior rather than implementation with fast execution and clear test names. Use this skill when writing unit tests, integration tests, or end-to-end tests, creating test files or test suites, testing critical user workflows, implementing test mocking or stubbing, writing test assertions, naming test cases descriptively, testing business-critical features, running tests during development, or working with test files in directories like __tests__, test/, spec/, or similar. Use when completing feature implementation and adding tests at logical completion points, not during intermediate development steps. Use when working with testing frameworks like Jest, Vitest, pytest, RSpec, JUnit, or any testing library.
---

## When to use this skill

- When writing unit tests for core functionality
- When writing integration tests for critical user flows
- When writing end-to-end tests for primary workflows
- When creating test files or test suites
- When testing business-critical features or paths
- When implementing test mocking, stubbing, or test doubles
- When writing test assertions and expectations
- When naming test cases descriptively
- When ensuring tests execute quickly (milliseconds for unit tests)
- When testing behavior rather than implementation details
- When working with test files in __tests__, test/, spec/, or similar directories
- When completing feature implementation at logical completion points
- When working with testing frameworks (Jest, Vitest, pytest, RSpec, JUnit, Mocha, etc.)
- When focusing on what code does, not how it does it

# Testing Test Writing

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle testing test writing.

## Instructions

For details, refer to the information provided in this file:
[testing test writing](../../../agent-os/standards/testing/test-writing.md)

Overview

This skill teaches how to write strategic, minimal tests that focus on core user flows and critical paths. It emphasizes testing observable behavior, fast execution, and clear, descriptive test names to keep suites reliable and maintainable. Use it to guide unit, integration, and end-to-end test design across popular frameworks.

How this skill works

The approach inspects the user-facing or API-facing behavior and identifies the smallest set of tests that exercise business-critical paths. Tests are written to assert outcomes and side effects rather than internal implementation details. It recommends fast, isolated unit tests for logic, focused integration tests for component interactions, and a few targeted end-to-end tests for primary workflows.

When to use it

  • Writing unit tests for core business logic that must be reliable and fast
  • Creating integration tests for critical interactions between modules or services
  • Adding end-to-end tests that cover primary user workflows and happy paths
  • Implementing mocks, stubs, or test doubles to isolate behavior under test
  • Naming test cases descriptively and organizing tests in __tests__, test/, or spec/ directories
  • After completing a feature at a logical handoff point, not during intermediate steps

Best practices

  • Test behavior, not implementation: assert outcomes, not private methods or internals
  • Keep tests minimal and focused: one assertion intent per test with clear setup
  • Prefer fast unit tests (milliseconds) and limit slow E2E tests to essential flows
  • Use descriptive test names that explain the scenario and expected result
  • Mock external dependencies and isolate flakiness with deterministic inputs
  • Group tests by feature or critical path, and run focused suites during development

Example use cases

  • Write unit tests for input validation and core transformation functions with no external network calls
  • Create integration tests that verify database writes and event emissions for a checkout flow
  • Add an E2E test that covers sign-up → email verification → first purchase
  • Name a test 'returns 400 when required field missing' instead of 'validation test 1'
  • Mock payment gateway responses to assert retry and error handling logic

FAQ

How many tests should I write for a feature?

Cover the critical paths and common edge cases: minimal unit tests for logic, one or two integration tests for interactions, and at most a couple of E2E tests for the primary workflow.

Should tests inspect private functions?

No. Focus on public behavior and outcomes. If you need to test internals, it often indicates a refactor to expose behavior through a public API.