0.1.0 • Published 9 years ago

nock-exec v0.1.0

Weekly downloads
49
License
-
Repository
github
Last release
9 years ago

Nock-exec is a child_process.exec mocking library for Node.js

Usage

In your test you can write:

var nockExec = require('nock-exec');
nockExec('myapp').err('some error').reply(0, 'This command was mocked');

This means that any call in the form

var exec = require('child_process').exec;
exec('myapp', function(error, stdout, stderr) {
   console.log('stdout: ' + stdout);
   console.log('stderr: ' + stderr);
   if (error !== null) {
     console.log('exec error: ' + error);
   }
});

will produce this output:

stdout: This command was mocked
stderr: some error