si

shell-inspect

Shell script testing framework

Showing:

Popularity

Downloads/wk

5

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

1

Size (min+gzip)

0.9KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

shell-inspect

Build Status

ShellInspect is a shell script testing library for node.js and the Mocha testing framework.

Example:

const inspect = require('inspectjs')
const shellInspect = require('shell-inspectjs')

describe('cow say'() => {
  it('should say hello', () => {
    return shellInspect.cmd('cowsay "Hello World!"').test((ctx) => {
      inspect(ctx.exitCode).isEqual(0)
      inspect(ctx.stdout).doesContain('Hello World!')
    })
  })
})

Methods

.cmd(str command) - Set the command which should get tested

Defines the command which one should get tested. Add here the full command, including all parameters and options.

shellInspect.cmd('git status -s').test(() => {

})

.cwd(str workingDir) - Set working dir

Defines the current working dir. The default working dir is process.cwd().

.test(func callback) - Callback method

Gets called when script has terminated. The callback method takes a context as its own argument.

callback(obj ctx)

Properties:

PropertyDescription
exitCodeContains the shell scripts exit code
pidThe used process id
textString representation of the shell output
errError message if anything went wrong
stdoutThe output stream
stderrThe error stream
runtimeThe script runtime as a Supertime duration object

Example:

shellInspect.cmd('git status -s').test((ctx) => {
  inspect(ctx.exitCode).isEql(0)
})

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100