Check before running bats does not exist: which bats
Check after running bats exists at nodemodule path which bats
If you have nvm and switch versions a reinstall may be required.
Putting the following into terminal will setup a bash test suite example using NPM global packages.
## remove potential previous bats installation:
## rm -rf /usr/local/bats;
npm install -g bats &&
npm install -g bats-assert &&
npm install -g bats-support@git+https://github.com/ztombol/bats-support.git#v0.2.0 &&
mkdir bats_test_suite_example &&
cd bats_test_suite_example &&
echo '
node_module_path() {
bats_location=$(which bats);
echo "${bats_location%/*/*/*/*}";
}
load "$(node_module_path)/bats-assert/load.bash";
load "$(node_module_path)/bats-support/load.bash";
' >> helpers.bash &&
echo '
#!/usr/bin/env bats
load 'helpers';
@test "addition using bc" {
result="$(echo 2+2 | bc)"
[ "$result" -eq 4 ]
}
@test "assert_equal()" {
assert_equal "have" "want"
}
' >> addition.bats &&
bats addition.bats
Uninstall using: