I am trying to write some CucumberJS attributes, which will test a nodes JS command line application that I am creating , Though I am running in Problems executing a child_process
within a feature stage
To get the proof of just the concept, I am trying to execute ls -l
I have a code;
requires ChildProcess = ('child_process'); Function execCmd () {console.log ('test command ...'); Var bin = childprocess.exec ('ls -l', {timeout: 5}, function (error, stdout, stderr) {console.log ('execution ...'); console.log (error); console.log (Stdout); console.log (stderr);}); Bin.on ('exit', function (code) {console.log ('code:' + code);}); } Module.exports = function () {this.Given (/ ^ I am at command line $ /, function (callback) {execCmd (); callback ();}); }
Implemented cucumber-js
does not do anything with the executable command. The output is as follows:
test order .... 1 scenario (passed 1) 1 step (passed 1)
But if I call I have seen, which does not answer the question and only shows how the command should be executed and it is not specific to running within a CaikbariJS stage. Thank you I believe this issue is due to some things: / P> I believe this will solve your problem: execCmd ()
after the function definition, then the module
var ChildProcess = Required ('child_process'); Function execCmd (cb) {console.log ('test command ...'); Var bin = childprocess.exec ('ls -l', {timeout: 5}, function (error, stdout, stderr) {console.log ('execution ...'); console.log (error); console.log (Stdout); console.log (stderr); cb ();}); } Module.exports = function () {this.Given (/ ^ I am at command line $ /, function (callback) {execCmd (callback);}); }
Comments
Post a Comment