https://github.com/drevops/bats-helpers
🦇 Helpers and assertions for BATS testing
https://github.com/drevops/bats-helpers
assertions bash bats bats-core shell testing unittest
Last synced: about 2 months ago
JSON representation
🦇 Helpers and assertions for BATS testing
- Host: GitHub
- URL: https://github.com/drevops/bats-helpers
- Owner: drevops
- License: gpl-3.0
- Created: 2023-03-20T11:38:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-28T18:38:29.000Z (2 months ago)
- Last Synced: 2025-07-30T05:52:11.239Z (2 months ago)
- Topics: assertions, bash, bats, bats-core, shell, testing, unittest
- Language: Shell
- Homepage: https://bats-helpers.drevops.com/
- Size: 1.26 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
BATS helpers
[](https://github.com/drevops/bats-helpers/issues)
[](https://github.com/drevops/bats-helpers/pulls)
[](https://github.com/drevops/bats-helpers/actions/workflows/test-shell.yml)
[](https://codecov.io/gh/drevops/bats-helpers)


---
Helpers and assertions for BATS testing.
Documentation## Features
- [Assertions](docs/assertions.md)
- [Data provider](docs/data-provider.md)
- [Helpers](docs/helpers.md)
- [Mocking](docs/mocking.md)
- [Step runner](docs/step-runner.md)## Installation
```bash
npm install -D bats-helpers@npm:@drevops/bats-helpers
```## Usage
1. Create a `_loader.bash` file next to your BATS tests with content:
```bash
export BATS_LIB_PATH="${BATS_TEST_DIRNAME}/../node_modules"
bats_load_library bats-helpers
```2. Use `load _loader.bash` in every BATS file:
```bash
#!/usr/bin/env bats
load _loader@test "My test" {
run ls
assert_success
}
```## Why not `bats-assert`, `bats-file`, `bats-support`
The goal is to merge this package with [bats-assert](https://github.com/bats-core/bats-assert).
However:
1. This package has more assertions and tests. They were battle-tested on many
projects and were waiting for BATS to provide support for library
functionality to be extracted into a standalone package.
2. Those packages have outdated version constraints which leads to conflicts.
3. This package has an extensive unit test suite with coverage. We also test on multiple OSes.## Acknowledgments
The mocking functionality is based on
the [bats-mock](https://github.com/grayhemp/bats-mock) project.
A special thank you to the contributors for their original work.## Maintenance
npm install
npm run lint
npm run test
### Publishing
npm version minor
git push
npm publish
---
_This repository was created using the [Scaffold](https://getscaffold.dev/) project template_