Skip to content

drevops/bats-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project logo

BATS helpers

GitHub Issues GitHub Pull Requests Test shell codecov GitHub release (latest by date) LICENSE Renovate


Helpers and assertions for BATS testing.
Documentation

Features

Installation

NPM

  1. Install the library:

    npm install -D bats-helpers@npm:@drevops/bats-helpers

    This will also install bats-core.

  2. 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
}

Why not bats-assert, bats-file, bats-support

The goal is to merge this package with 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 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 project template

Sponsor this project

  •  

Contributors 5

Languages