Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await server.start();
flags.onCleanup = async () => await server.stop();
// Create a user to follow/unfollow (referenced within postman collection)
await server.services().userService.signup({
username: 'rick',
password: 'secret-rick',
email: 'rick@rick.com'
});
// Run postman tests
const newman = Newman.run({
reporters: 'cli',
collection: require('./postman-collection.json'),
environment: {
values: [
{
enabled: true,
key: 'apiUrl',
value: `${server.info.uri}/api`,
type: 'text'
}
]
}
});
await Toys.event(newman, 'done');
function runNewman (collection, collectionName, done) {
responses = [];
newman.run({
collection: collection
}).on('beforeItem', function (err, summary) {
if (err) {
return done(err);
}
console.log('Sending request: ' + summary.item.name);
}).on('request', function (err, summary) {
if (err) {
return done(err);
}
var stdout = summary.response.stream.toString();
try {
stdout = JSON.parse(stdout);
}
catch (e) {
"use strict";
const newman = require('newman');
var config = JSON.parse(
unescape(process.argv[2])
.replace(new RegExp('<>', 'g'), '"'));
newman.run(config, function(err, summary) {
if (err) {
console.log(JSON.stringify(err, null, 1));
process.exit(2);
} else {
if (summary.run.failures && summary.run.failures.length > 0) {
process.exit(1);
}
}
});
exports.execute = function (testModules, newmanOptions, callback) {
var pjson = require('./package.json')
console.log('Jetman version ' + pjson.version)
var collection = this.createCollection(testModules)
var options = _.extend({collection: collection, reporters: 'cli'}, defaultNewmanOptions, newmanOptions)
newman.run(
options,
callback
)
}
function runNewman (options) {
newman.run(options).on('done', (err, summary) => {
if (err || summary.run.failures.length) {
core.setFailed('Newman run failed!' + (err || ''))
}
})
}