Skip to main content

Introduction

The bats-helpers package is an extension to the BATS core testing framework, offering enhanced functionality and a larger set of assertions and tests.

Features

Installation

NPM

  1. Install the library:
npm install -D bats-helpers@npm:@drevops/bats-helpers

This will also install bats-core.

  1. Create a _loader.bash file next to your BATS tests with content:
export BATS_LIB_PATH="${BATS_TEST_DIRNAME}/../node_modules"
bats_load_library bats-helpers

From source

  1. Click Code -> Download ZIP in the GitHub UI.
  2. Extract files to a desired location. Usually, next to where bats-core is located.
  3. Create a _loader.bash file next to your BATS tests with content:
export BATS_LIB_PATH="<path/to/extracted/files>"
bats_load_library bats-helpers

Usage

Use load _loader.bash in every BATS file:

#!/usr/bin/env bats
load _loader

@test "My test" {
run ls
assert_success
}