Acceptance testing framework for CLI applications
npm install douglasduteil...shelltestJS acceptance testing framework for CLI applications.
npm install shelltest --save
`
Example
`javascript
shelltest()
.cmd("/usr/bin/my_command")
.expect('stdout', /^regex.match/)
.end();
`$3
`javascript
it('should run the command', function(done){
shelltest()
.cmd("/usr/bin/my_command")
.expect('stdout', /^match/)
.expect(0)
.end(done);
});
`
API
$3
Sets the command to be executed.
`javascript
.cmd("/bin/my_command")
`$3
Adds an assertion. All assertions are evaluated when .end(fn) is called.
`javascript
.expect('stderr', /^regex.match/) //Asserts stderr
.expect('stdout', 'string match') //Asserts stdout
.expect(0) //Asserts exit code
`$3
Sets child_process cwd option.
`javascript
.cwd('/var')
`$3
Sets child_process env option.
`javascript
.env({"PATH": "/usr/cust:/usr/bin"})
`$3
Sets child_process timeout option.
`javascript
.timeout(10)
`$3
Sets child_process uid option.
`javascript
.uid(0)
`$3
Sets child_process gid option.
`javascript
.gid(0)
`$3
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 error
- stdout: the output string
- stderr: the error string
`javascript
.end(callback_function)
``