unit-testing

Generate pytest unit test templates with fixtures and mocks.

17|1|Updated Jun 8, 2025
One-click install
npx skills add https://github.com/williamzujkowski/standards --skill unit-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unit-testing
Source: https://github.com/williamzujkowski/standards/tree/main/skills/testing/unit-testing
Command: npx skills add https://github.com/williamzujkowski/standards --skill unit-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This skill provides best practices for writing effective unit tests, ensuring individual code components function correctly in isolation. It streamlines the adoption of mocking, Test-Driven Development (TDD), and code coverage analysis, reducing bugs and improving code quality.

Core Features & Use Cases

  • Mocking Strategies: Guides on isolating units of code using mocks, stubs, and spies for focused testing.
  • Test-Driven Development (TDD): Teaches the TDD cycle to design better code through testing.
  • Code Coverage Analysis: Provides configurations and tools to measure and improve test coverage.
  • Use Case: Write unit tests for a new Python function using pytest, automatically generating a test template with fixtures and mocks to ensure comprehensive coverage.

Quick Start

Generate a pytest unit test template for a Python function, including a mock for an external dependency.

Frequently Asked Questions about unit-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests that catch bugs before they reach production?

Unit testing validates individual code components in isolation, catching defects early. This Skill covers pytest and Jest workflows with mocking and fixtures to ensure comprehensive coverage—typically 80-90%—and reduce bugs through fast, focused tests.

What's the best way to structure pytest tests for a Python project?

Organize pytest tests using fixtures for setup, mocks to isolate dependencies, and parametrized tests for multiple scenarios. This Skill provides reusable templates and naming conventions that keep test structure maintainable and consistent across your codebase.

Can I use mocking and TDD together to improve test quality?

Yes. Test-Driven Development combined with mocking isolates units effectively. This Skill teaches the TDD cycle—write tests first, then code—alongside mocking strategies that focus each test on one component while stubbing external dependencies.

How do I measure and improve code coverage in Jest or pytest?

Code coverage analysis measures what percentage of your code is tested. This Skill configures coverage tools for both Jest and pytest, showing which lines lack tests and how to reach the 80-90% target for robust, maintainable components.

Does this apply to both Python and JavaScript projects?

Yes. This Skill covers best practices for Python (pytest) and JavaScript (Jest) projects at all levels—from quick-start templates through mastery of the test pyramid, mocking, TDD workflows, and CI integration.

Why should I use the test pyramid instead of writing only end-to-end tests?

The test pyramid prioritizes fast, isolated unit tests at the base, reducing feedback loops and maintenance overhead. This Skill explains the pyramid structure and shows how unit tests catch bugs cheaply before slower integration and end-to-end tests run.