shell-testing

Installation
SKILL.md

Shell Testing with BATS

Running Tests — Targeted Only

NEVER run the full test suite. Always run only the test files affected by the current changes.

  1. Map source → test file: lib/helpers.shtests/helpers.bats, lib/ui.shtests/ui.bats, cmd/theme/*tests/theme.bats
  2. Run specific files: bats tests/helpers.bats tests/theme.bats
  3. Filter by name: bats tests/helpers.bats --filter "format_insert"
  4. Filter by tag: bats tests/ --filter-tags "unit"

When multiple source files changed, run only their corresponding test files. If unsure which tests cover a function, grep for the function name across tests/*.bats.

Framework Decision

  • BATS (primary): All bash code, polyglot bash/zsh code, CLI commands
  • Zunit: Only for pure zsh features (completions, zle widgets, zstyle) that cannot be tested via BATS
  • bats --shell zsh (BATS 1.8.0+): Run BATS tests under zsh for polyglot verification
Related skills
Installs
6
GitHub Stars
1
First Seen
Mar 5, 2026