An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          



Project logo

BATS helpers

[![GitHub Issues](https://img.shields.io/github/issues/drevops/bats-helpers.svg)](https://github.com/drevops/bats-helpers/issues)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/drevops/bats-helpers.svg)](https://github.com/drevops/bats-helpers/pulls)
[![Test shell](https://github.com/drevops/bats-helpers/actions/workflows/test-shell.yml/badge.svg)](https://github.com/drevops/bats-helpers/actions/workflows/test-shell.yml)
[![codecov](https://codecov.io/gh/drevops/bats-helpers/graph/badge.svg?token=O0ZYROWCCK)](https://codecov.io/gh/drevops/bats-helpers)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/bats-helpers)
![LICENSE](https://img.shields.io/github/license/drevops/bats-helpers)
![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)

---

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_