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.

referencesjavainline.md

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

Java Inline Approvals

Inline approvals store expected output directly in test code using Java text blocks (""").

Contents

Basic Usage

import org.approvaltests.Approvals;
import org.approvaltests.core.Options;

@Test
void testGreeting() {
    var expected = """
        Hello World!
        Welcome to inline approvals!
        """;
    Approvals.verify(getGreeting(), new Options().inline(expected));
}

When the test fails, the framework automatically updates expected with the actual output.

InlineOptions Modes

Automatic Mode

Auto-approves and updates source code immediately:

var expected = "";
Approvals.verify(actual, new Options().inline(expected, InlineOptions.automatic()));

Semi-Automatic Mode

Adds a marker that must be manually deleted to approve:

var expected = """
    actual output here
    ***** DELETE ME TO APPROVE *****
    """;
Approvals.verify(actual, new Options().inline(expected, InlineOptions.semiAutomatic()));

Delete the ***** DELETE ME TO APPROVE ***** line to approve.

Semi-Automatic with Previous

Shows previous approved value for comparison:

var expected = """
    new output
    vvvvv PREVIOUS RESULT vvvvv
    old output
    """;
Approvals.verify(actual, new Options().inline(expected,
    InlineOptions.semiAutomaticWithPreviousApproved()));

With Code Display

Show source code context in diff:

Approvals.verify(actual, new Options().inline(expected, InlineOptions.showCode(true)));

Kotlin Support

Uses Kotlin string templates with trimIndent():

@Test
fun `test greeting`() {
    val expected = """
        Hello World!
        Welcome to inline approvals!
        """.trimIndent()
    Approvals.verify(getGreeting(), Options().inline(expected))
}

How It Works

  1. Test fails → InlineJavaReporter activates
  2. Reporter finds test method via stack trace
  3. Parses source file and locates the expected variable
  4. Replaces the text block content with actual output
  5. Rewrites source file

When to Use Inline vs File Approvals

Use inline when:

  • Output is short (few lines)
  • You want test and expectation in one place
  • Quick iteration during TDD

Use file approvals when:

  • Output is long or complex
  • Multiple tests share similar output patterns
  • Binary content (images, PDFs)
  • JSON/XML that benefits from syntax highlighting

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