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.

referencespythonreporters.md

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

Python Reporters

Reporters handle what happens when an approval fails - showing diffs, opening diff tools, or custom actions.

Contents

Using Factory

from approvaltests import verify, Options
from approvaltests.reporters import GenericDiffReporterFactory

factory = GenericDiffReporterFactory()
reporter = factory.get("BeyondCompare")
verify("Hello", options=Options().with_reporter(reporter))

Available reporters include: BeyondCompare, DiffMerge, KDiff3, Meld, P4Merge, TkDiff, VSCode, IntelliJ.

Custom Diff Tool

from approvaltests import verify, Options
from approvaltests.reporters import GenericDiffReporter

reporter = GenericDiffReporter.create("/path/to/diff/tool")
verify("Hello", options=Options().with_reporter(reporter))

Custom Reporter Class

from approvaltests import verify, Options
from approvaltests.core.reporter import Reporter

class MyReporter(Reporter):
    def report(self, received_path: str, approved_path: str) -> bool:
        print(f"Mismatch: {received_path} vs {approved_path}")
        return True

verify(result, options=Options().with_reporter(MyReporter()))

The report method receives paths to both files. Return True if the reporter handled the failure.

Chaining Reporters

Use FirstWorkingReporter to try multiple reporters in order:

from approvaltests import verify, Options
from approvaltests.reporters import FirstWorkingReporter, GenericDiffReporterFactory
from approvaltests.reporters import PythonNativeReporter

factory = GenericDiffReporterFactory()
reporter = FirstWorkingReporter(
    factory.get("VSCode"),
    factory.get("IntelliJ"),
    PythonNativeReporter(),
)
verify("Hello", options=Options().with_reporter(reporter))

Falls back through the list until one works.

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