I am new to Cucumber.js, trying to execute a shell command in a step definition. Sample below is a step definition snippet, Cucumber.js does not print stdout. I basically need to access stdout and stderr in a step.
var exec = require('child_process').exec;
this.Given(/^XYZ server is running$/, function(callback) {
child = exec('pwd', function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
callback();
});
Looks like a good example on nodejitsu.