New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

bats-zsh

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bats-zsh

Wrapper enabling Bats to test functions in Zsh scripts

latest
Source
npmnpm
Version
1.2.1
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

bats-zsh

license GitHub release npm tests

Wrapper enabling Bats to source and test Zsh scripts.

Install

npm is the preferred installation method.

npm install bats-zsh

Usage

This project provides the following functions:

zsource

Used in place of source to source 1 or more Zsh files.

@test 'zsource sample test'{
    zsource path/to/zsh-file1.sh
    zsource path/to/zsh-file2.sh
}

When multiple files are sourced using zsource, conflicts will be handled the same as source would. In effect, when there is a conflict, the newer version will overwrite the older one.

zrun

Used in place of run to run a function from the sourced Zsh script.

@test 'output_number_of_args() outputs the number of args' {
    zsource path/to/zsh-file.sh
    zrun output_number_of_args arg1 arg2 arg3

    [ "$status" -eq 0 ]
    [ "$output" = "there were 3 args" ]
    [ "$BATS_RUN_COMMAND" = "zrun output_number_of_args arg1 arg2 arg3" ]
}

All variables expected from run will be set (i.e. status, output, and BATS_RUN_COMMAND).

zset

Used to set or change global variables in the sourced files.

@test 'say_my_name() outputs \$MY_NAME'{
    zsource path/to/zsh-file.sh

    zrun say_my_name

    [ "$output" = "You don't have a name" ]

    zset MY_NAME="David"

    zrun say_my_name

    [ "$output" = "Your name is David" ]
}

Testing

  • Clone this repository: git clone https://github.com/targendaz2/bats-zsh.git
  • Install global dependencies: Node.js, ShellCheck, & Zsh
  • Install project dependencies: npm install
  • Run shellcheck: npm run shellcheck
  • Run tests: npm test test

Keywords

bats

FAQs

Package last updated on 28 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts