I want to execute newman
from node.js module but it dose not work. and no error shown.
working well from command line
newman run postman-tests/collection.json -e postman-tests/environment.json
// newman installed globally for this command
but bellow node module code not working:
var newman = require('newman'),
Promise = require('bluebird'),
newmanRun = Promise.promisify(newman.run);
//.. other working grunt task here ...
// added new task postman-test
grunt.registerTask('postman-test','postman task running ', function() {
Promise.coroutine(function*() {
try {
console.log('test start-----');
var response = yield newmanRun({
collection: require('./postman-tests/collection.json'),
environment: require('./postman-tests/environment.json'),
reporters: 'cli'
});
console.log('run complete-----', response);
} catch (e) {
console.log('postman test catch error: ', e);
}
})();
});
when I run "grunt postman-test" command shown in console "test start-----"
only and shown Done, without errors.
but no test execute
whats wrong in my code ? can any one help me?
By default, grunt treats all task registrations synchronously.Chances are this is happening because you have forgotten to call the this.async
method to tell Grunt that your task is asynchronous.For simplicity's sake, Grunt uses a synchronous coding style, which can be switched to asynchronous by calling this.async()
within the task body. doc link
grunt.registerTask('postman-test', function() {
var done = this.async();// added this line
Promise.coroutine(function*() {
try {
yield newmanRun({
collection: "./postman-tests/0.8/Meed-Services-0.8.postman_collection.json",
environment: "./postman-tests/0.8/local.postman_environment.json",
reporters: 'cli'
});
console.log('*******postman test complete********');
done();
} catch (e) {
console.log('postman test catch error: ', e);
done(false);
}
})();
});