Last active
January 4, 2016 20:49
-
-
Save lxe/8676227 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // run with "mocha mocha-proc.js" | |
| var spawn = require('child_process').spawn | |
| , should = require('should') | |
| describe('your thing', function () { | |
| it('should do some stuff', function (done) { | |
| var ls = spawn('ls', ['-lh', '/usr']); | |
| ls.stdout.on('data', function (data) { | |
| // Check for data, call done() | |
| console.log('stdout: ' + data); | |
| }); | |
| ls.stderr.on('data', function (data) { | |
| // OR check for data and call done() or throw some errors | |
| console.log('stderr: ' + data); | |
| }); | |
| ls.on('close', function (code) { | |
| // OR check for status code and call done() | |
| console.log('child process exited with code ' + code); | |
| code.should.equal(0); | |
| done(); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment