bats-test-scaffolder

Generate BATS test structure and fixtures for shell script testing with setup/teardown, assertions, and mocking.

509 stars

Best use case

bats-test-scaffolder is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generate BATS test structure and fixtures for shell script testing with setup/teardown, assertions, and mocking.

Teams using bats-test-scaffolder should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/bats-test-scaffolder/SKILL.md --create-dirs "https://raw.githubusercontent.com/a5c-ai/babysitter/main/library/specializations/cli-mcp-development/skills/bats-test-scaffolder/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/bats-test-scaffolder/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How bats-test-scaffolder Compares

Feature / Agentbats-test-scaffolderStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generate BATS test structure and fixtures for shell script testing with setup/teardown, assertions, and mocking.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# BATS Test Scaffolder

Generate BATS test structure for shell script testing.

## Capabilities

- Generate BATS test files
- Create setup and teardown fixtures
- Implement custom assertions
- Set up mocking helpers
- Configure test isolation
- Generate test helpers

## Usage

Invoke this skill when you need to:
- Set up BATS testing for shell scripts
- Create test fixtures and helpers
- Implement mock functions
- Generate test cases

## Generated Test Structure

```
tests/
├── bats/
│   └── bats-*.bash        # BATS submodules
├── test_helper/
│   ├── common-setup.bash  # Common setup
│   └── mocks.bash         # Mock helpers
├── fixtures/
│   ├── input.txt          # Test fixtures
│   └── expected.txt
└── *.bats                  # Test files
```

## Test File Template

```bash
#!/usr/bin/env bats

# Load test helpers
load 'test_helper/common-setup'

# Setup runs before each test
setup() {
    common_setup
    # Test-specific setup
    export TEST_DIR="$(mktemp -d)"
}

# Teardown runs after each test
teardown() {
    # Cleanup
    rm -rf "${TEST_DIR}"
}

@test "script displays help with --help" {
    run ./script.sh --help

    assert_success
    assert_output --partial "Usage:"
}

@test "script fails without required argument" {
    run ./script.sh

    assert_failure
    assert_output --partial "Missing required argument"
}

@test "script processes input file" {
    cp fixtures/input.txt "${TEST_DIR}/"

    run ./script.sh "${TEST_DIR}/input.txt"

    assert_success
    assert_output --partial "Processing complete"
}

@test "script creates output file" {
    run ./script.sh -o "${TEST_DIR}/output.txt" fixtures/input.txt

    assert_success
    assert_file_exists "${TEST_DIR}/output.txt"
}

@test "script handles special characters in filename" {
    local special_file="${TEST_DIR}/file with spaces.txt"
    echo "test" > "${special_file}"

    run ./script.sh "${special_file}"

    assert_success
}
```

## Test Helper (test_helper/common-setup.bash)

```bash
#!/usr/bin/env bash

# Load BATS support libraries
load 'bats/bats-support/load'
load 'bats/bats-assert/load'
load 'bats/bats-file/load'

# Common setup for all tests
common_setup() {
    # Get the containing directory
    PROJECT_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"

    # Add scripts to PATH
    PATH="${PROJECT_ROOT}/bin:${PATH}"

    # Set up test temp directory
    TEST_TEMP_DIR="$(mktemp -d)"
}

# Common teardown
common_teardown() {
    rm -rf "${TEST_TEMP_DIR}"
}

# Custom assertion: check exit code
assert_exit_code() {
    local expected="$1"
    if [[ "${status}" -ne "${expected}" ]]; then
        echo "Expected exit code ${expected}, got ${status}" >&2
        return 1
    fi
}

# Mock a command
mock_command() {
    local cmd="$1"
    local response="$2"

    eval "${cmd}() { echo '${response}'; }"
    export -f "${cmd}"
}
```

## Target Processes

- shell-script-development
- cli-unit-integration-testing
- cross-platform-cli-compatibility

Related Skills

vitest

509
from a5c-ai/babysitter

Vitest configuration, mocking, coverage, snapshot testing, and performance.

react-testing-library

509
from a5c-ai/babysitter

React Testing Library patterns, queries, user events, and accessibility testing.

load-test-generator

509
from a5c-ai/babysitter

Generate load test scripts for k6, Locust, and Gatling from OpenAPI specs

cloud-security-testing

509
from a5c-ai/babysitter

Multi-cloud security assessment and penetration testing capabilities. Execute Prowler/ScoutSuite assessments, analyze IAM policies, identify cloud misconfigurations, test permissions, and enumerate cloud resources across AWS/GCP/Azure.

contract-test-framework

509
from a5c-ai/babysitter

Consumer-driven contract testing for SDK-API compatibility. Generate Pact consumer tests, verify provider contracts, configure Pact broker, and implement can-i-deploy checks.

compatibility-test-matrix

509
from a5c-ai/babysitter

Multi-version, multi-platform SDK compatibility testing

test-data-generation

509
from a5c-ai/babysitter

Synthetic test data generation and management using Faker.js and similar tools. Generate realistic test data, create data factories, implement database seeding, and manage test data anonymization.

Stryker Mutation Testing

509
from a5c-ai/babysitter

Stryker mutation testing for assessing test suite quality and effectiveness

pytest Testing

509
from a5c-ai/babysitter

Expert pytest framework for Python unit, integration, and functional testing

Playwright E2E Testing

509
from a5c-ai/babysitter

Deep integration with Playwright for browser automation and end-to-end testing

Percy Visual Testing

509
from a5c-ai/babysitter

Percy visual testing platform integration for visual regression detection

pact-contract-testing

509
from a5c-ai/babysitter

Consumer-driven contract testing with Pact framework. Generate consumer contracts, configure Pact Broker publishing, execute provider verification, detect breaking changes, and integrate with CI/CD pipelines.