Registry / testing / bats-support

bats-support

JSON →
library0.3.0jsnpmunverified

bats-support is a supporting library for Bats (Bash Automated Testing System) test helpers, providing common functions for error reporting, output formatting, and language tools. Version 0.3.0 is the latest stable release with no active maintenance cadence announced. It serves as a dependency for higher-level assertion libraries like bats-assert, focusing on internal helper utilities rather than end-user assertions. Key differentiators include its lightweight shell implementation, strict adherence to Bats conventions, and compatibility with both Bats 0.4 and 1.x. The library was renamed from bats-core to bats-support, with GitHub redirects ensuring backward compatibility.

npm install bats-support
INSTALL
IMPORT
SIG · BATS-SUPPORT
B
bats-support
testingjavascriptv0.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fail
load 'bats-support/load'
source bats-support/load.bash
Use the Bats 'load' function to properly initialize all helpers; direct sourcing may cause path issues.
batslib_is_caller
load 'bats-support/load'
source bats-support/src/caller.bash
All functions are exposed via the main load file; importing individual source files is incorrect and unsupported.
batslib_err
load 'bats-support/load'
require 'bats-support'
This library is not a Node.js or Ruby gem; use 'load' from within a Bats test file, not a package manager.

Demonstrates loading bats-support, using fail helper for custom error messages, and batslib_is_caller for call stack inspection.

#!/usr/bin/env bats load 'bats-support/load' @test 'fail helper works' { run some-command if [ "$status" -ne 0 ]; then fail "Expected success, but command failed with status $status" fi } @test 'batslib_is_caller example' { run bash -c ' function my_helper { batslib_is_caller --indirect "teardown" && echo "called from teardown" } my_helper ' [ "$output" = "called from teardown" ] }
Debug
Known issues
breakingRepository renamed from bats-core to bats-support; all references (submodules, clones) redirect automatically but should be updated.
fix
Update git submodule and file references to the new repository URL: https://github.com/bats-core/bats-support.git
affects: >=0.0
deprecatedDirect sourcing of individual source files (e.g., 'source bats-support/src/output.bash') is deprecated; always use 'load'.
fix
Replace with: load 'bats-support/load'
affects: >=0.0
gotchaThe 'fail' function reads from stdin if no argument is provided; piping to fail without checking may lead to unexpected failures.
fix
Always supply a message argument unless you intentionally want to pipe input.
affects: >=0.0
Errors
Common errors & fixes
bats: load: bats-support/load: file not found
bats-support is not installed or BATS_LIB_PATH is not set correctly.
fix
Install bats-support via git submodule or npm, and ensure BATS_LIB_PATH includes the parent directory of bats-support.
bats: unknown option: --indirect
Using an older version of bats-support that does not support the --indirect flag.
fix
Update bats-support to version 0.2.0 or later which introduced --indirect.
TypeError: batslib_err is not a function
Using Unix 'type' command or other shell that doesn't recognize batslib_err as a function (likely due to incorrect sourcing order).
fix
Ensure 'load bats-support/load' is placed before any calls to bats-support functions.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
batsoptionalruntime peer dependency for test execution framework
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
bats-support — npm install bats-support · libregistry