All skills
lexler avatar

/approval-tests

@83aee6a
by Lada Kesselerlexler/skill-factory238 stars
61

Writes approval tests (snapshot/golden master testing) for Python, JavaScript/TypeScript, or Java. Use when verifying complex output, characterization testing legacy code, testing combinations, or working with .approved/.received files.

Use this Skill: https://skilld.dev/gh/lexler/skill-factory/approval-tests

This session only. Nothing lands on disk.

referencespythoncombinations.md

≈915 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Python Combination Testing

Test all combinations of input parameters with a single approval file.

Contents

verify_all_combinations_with_labeled_input

Recommended. Parameter names appear in output.

from approvaltests import verify_all_combinations_with_labeled_input

def test_pricing():
    verify_all_combinations_with_labeled_input(
        calculate_price,
        size=["small", "medium", "large"],
        quantity=[1, 5, 10],
        with_discount=[True, False],
    )

Output:

(size: small, quantity: 1, with_discount: True) => 8.50
(size: small, quantity: 1, with_discount: False) => 10.00
(size: small, quantity: 5, with_discount: True) => 42.50
...

verify_all_combinations

Positional arguments. Less readable output, but works for simple cases.

from approvaltests import verify_all_combinations

def test_pricing():
    verify_all_combinations(
        calculate_price,
        [
            ["small", "medium", "large"],
            [1, 5, 10],
            [True, False],
        ]
    )

Output:

[small, 1, True] => 8.50
[small, 1, False] => 10.00
...

verify_best_covering_pairs

Pairwise testing - covers all two-parameter combinations with fewer test cases. Requires allpairspy.

from approvaltests import verify_best_covering_pairs

def test_pricing():
    verify_best_covering_pairs(
        calculate_price,
        [
            ["small", "medium", "large"],
            [1, 5, 10, 20, 50],
            [True, False],
            ["standard", "express", "overnight"],
        ]
    )

Full combinations: 3×5×2×3 = 90 tests Pairwise: ~15-20 tests, still covers all parameter pairs

Handling Edge Cases

Include None and empty values

from approvaltests import verify_all_combinations_with_labeled_input

def test_user_creation():
    verify_all_combinations_with_labeled_input(
        create_user,
        name=["Alice", "", None],
        email=["a@b.com", "invalid", None],
        age=[25, 0, -1, None],
    )

Handling exceptions

Exceptions appear in output as error messages:

from approvaltests import verify_all_combinations_with_labeled_input

def test_division():
    verify_all_combinations_with_labeled_input(
        lambda a, b: a / b,
        a=[10, 0],
        b=[2, 0],
    )

Output:

(a: 10, b: 2) => 5.0
(a: 10, b: 0) => ZeroDivisionError: division by zero
(a: 0, b: 2) => 0.0
(a: 0, b: 0) => ZeroDivisionError: division by zero

Custom formatting

from approvaltests import verify_all_combinations_with_labeled_input

def format_result(result):
    if isinstance(result, float):
        return f"${result:.2f}"
    return str(result)

def test_pricing():
    verify_all_combinations_with_labeled_input(
        calculate_price,
        size=["S", "M", "L"],
        quantity=[1, 10],
        formatter=format_result,
    )

When to Use Which

Use verify_all_combinations_with_labeled_input (recommended):

  • Most cases
  • When output readability matters
  • When parameter names help understand the test

Use verify_all_combinations:

  • Simple positional functions
  • When you already have lists of values

Use verify_best_covering_pairs:

  • 4+ parameters with many values each
  • Full combinations would be hundreds/thousands
  • Most bugs involve 2-parameter interactions

Source: SKILL.md on GitHub

1 warning6d4 checks · Risk SAFE
  • Gen Agent Trust Hub6d

    The skill provides instructions and patterns for implementing approval testing (snapshot testing) across multiple programming languages. It includes capabilities for file system operations, command execution for testing CLI tools, and launching external diff reporters, which are consistent with the skill's purpose. The analysis identified an indirect prompt injection surface when verifying external or untrusted data.

  • Socket6d

    No alerts

  • Snyk6d

    Risk: LOW · No issues

  • Runlayer7mo

    25/25 files flagged

Signed by skilld at 83aee6a. 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 8 months ago

README badge

README badge for lexler/skill-factory/approval-tests