nock-exec

0.1.0 • Public • Published

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

/nock-exec/

    Package Sidebar

    Install

    npm i nock-exec

    Weekly Downloads

    462

    Version

    0.1.0

    License

    none

    Last publish

    Collaborators

    • vlad-c