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.

referencesjavareporters.md

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

Java Reporters

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

Contents

Using Reporters

Via Annotation (class-level)

import org.approvaltests.reporters.UseReporter;
import org.approvaltests.reporters.intellij.IntelliJReporter;

@UseReporter(IntelliJReporter.class)
public class MyTest {
    @Test
    void testSomething() {
        Approvals.verify(result);
    }
}

Via Options (per-test)

Approvals.verify(result, new Options().withReporter(new Junit5Reporter()));

Available Reporters

IDE Reporters

@UseReporter(IntelliJReporter.class)
@UseReporter(EclipseReporter.class)
@UseReporter(VsCodeReporter.class)

Diff Tool Reporters

@UseReporter(BeyondCompare4Reporter.class)     // Windows/Mac
@UseReporter(KaleidoscopeDiffReporter.class)   // Mac
@UseReporter(MeldMergeReporter.class)          // Linux
@UseReporter(TortoiseDiffReporter.class)       // Windows
@UseReporter(P4MergeReporter.class)            // Cross-platform
@UseReporter(KDiff3Reporter.class)             // Cross-platform

JUnit Reporters

@UseReporter(Junit4Reporter.class)
@UseReporter(Junit5Reporter.class)

CI/Utility Reporters

@UseReporter(QuietReporter.class)        // Silent fail, no diff output
@UseReporter(ClipboardReporter.class)    // Copies approve command to clipboard
@UseReporter(AutoApproveReporter.class)  // Auto-approves (use with caution)
@UseReporter(DiffReporter.class)         // System default diff tool

FirstWorkingReporter

Try reporters in order until one works:

import org.approvaltests.reporters.FirstWorkingReporter;

@UseReporter(FirstWorkingReporter.class)
public class MyTest {
    // Tries reporters in order: IntelliJ → VS Code → Beyond Compare → Clipboard
}

Custom chain via Options:

Reporter chain = new FirstWorkingReporter(
    new IntelliJReporter(),
    new VsCodeReporter(),
    new ClipboardReporter()
);
Approvals.verify(result, new Options().withReporter(chain));

Custom Reporter

Implement the Reporter interface:

import org.approvaltests.core.ApprovalFailureReporter;

public class MyReporter implements ApprovalFailureReporter {
    @Override
    public boolean report(String received, String approved) {
        System.out.println("Mismatch:");
        System.out.println("  Received: " + received);
        System.out.println("  Approved: " + approved);
        return true;  // true = reporter handled it
    }
}

// Usage
@UseReporter(MyReporter.class)
public class MyTest { }

PackageSettings

Set default reporter for all tests in a package:

package org.myapp.tests;

import org.approvaltests.reporters.UseReporter;
import org.approvaltests.reporters.intellij.IntelliJReporter;

@UseReporter(IntelliJReporter.class)
public class PackageSettings {
    // Applies to all tests in this package and subpackages
}

For package-wide configuration details, see advanced.md.

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