home / skills / alekspetrov / navigator / backend-test

backend-test skill

/skills/backend-test

This skill auto-generates backend tests for Python projects, including unit and integration tests with fixtures and mocks, ensuring coverage and reliability.

npx playbooks add skill alekspetrov/navigator --skill backend-test

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

Files (1)
SKILL.md
952 B
---
name: backend-test
description: Generate backend tests (unit, integration, mocks). Auto-invoke when user says "write test for", "add test", "test this", or "create test".
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
version: 1.0.0
---

# Backend Test Generator

Generate comprehensive backend tests with Jest/Vitest including fixtures and mocks.

## When to Invoke

Auto-invoke when user mentions:
- "Write test for"
- "Add test"
- "Test this"
- "Create test"
- "Test [component/function]"

## What This Does

1. Generates test file with describe/it blocks
2. Creates test fixtures
3. Generates mocks for dependencies
4. Includes edge cases
5. Follows testing best practices

## Success Criteria

- [ ] Test file generated with proper structure
- [ ] Tests cover happy path and error cases
- [ ] Mocks isolate unit under test
- [ ] Fixtures provide test data
- [ ] Tests are runnable and pass

**Auto-invoke when writing backend tests** ๐Ÿงช

Overview

This skill generates backend tests for Python projects, including unit, integration, and mocked tests. It auto-invokes when you ask to write or add tests and produces runnable test files, fixtures, and dependency mocks. The output focuses on clear structure, edge cases, and maintainability.

How this skill works

On invocation it inspects the target code to identify functions, classes, and external dependencies, then scaffolds test files with describe/it-style sections adapted for pytest. It creates fixtures and mock objects to isolate the unit under test, adds happy-path and error-case tests, and includes instructions or commands to run the tests. The generator aims to produce tests that are runnable immediately and easy to extend.

When to use it

  • When you say: "write test for", "add test", "test this", or "create test"
  • When adding tests for new backend functions, API handlers, or services
  • When you need mocks for external dependencies like databases or HTTP clients
  • When converting manual checks into automated unit or integration tests
  • When you want a baseline of edge-case coverage quickly

Best practices

  • Generate one test file per module and keep tests small and focused
  • Use fixtures to centralize test data and avoid repetition
  • Mock external services to isolate behavior; prefer dependency injection
  • Cover happy path, expected failures, and boundary conditions
  • Name tests clearly and include setup/teardown when side effects exist

Example use cases

  • Create pytest unit tests for a data validation function with multiple input cases
  • Scaffold integration tests for an API endpoint using test client and temporary DB
  • Generate mocks for an external payment gateway to test error handling
  • Add fixture-based tests for a service that transforms incoming messages
  • Produce tests that verify retry logic and exception branches in background jobs

FAQ

Which test framework does this target?

It produces pytest-compatible tests by default but can adapt structure to other Python test frameworks on request.

Will generated tests run out of the box?

Yes โ€” tests include necessary fixtures and mock scaffolds and a brief command to run them, assuming standard project layout and dependencies.