shelltest
JS acceptance testing framework for CLI applications.
Purpose
This framework is intended to serve as a friendly layer of abstraction for testing the stdout, stderr, and exit code of shell commands. It's like supertest, but for CLI apps.
Installation
npm install shelltest --save
Example
;
With Mocha
;
API
.cmd(command)
Sets the command to be executed.
.expect(value, match)
Adds an assertion. All assertions are evaluated when .end(fn)
is called.
//Asserts stderr //Asserts stdout //Asserts exit code
.cwd(cwd)
Sets child_process
cwd option.
.env(env)
Sets child_process
env option.
.timeout(timeout)
Sets child_process
timeout option.
.uid(uid)
Sets child_process
uid option.
.gid(gid)
Sets child_process
gid option.
.end([fn])
Executes command and evaluates assertions. end()
will throw with no callback.
Callback is fired with fn(err, stdout, stderr)
:
err
: null or the assert or process errorstdout
: the output stringstderr
: the error string