-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (49 loc) · 1.39 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var _ = require('lodash');
function createSummary(summary) {
var executions = [];
summary.run.executions.forEach(function(execution) {
if(execution.response.code >= 400) {
executions.push({
'TestId': execution.item.id,
'Request': {
'Path': execution.request.url.path
},
'Response': {
'Status': execution.response.status,
'Code': execution.response.code,
'Stream': execution.response.stream
}
});
}
});
// Build main object with just the bits needed plus the slimmed down failures
var result = {};
Object.assign(result, {
'Collection': {
'Info': {
'Name': summary.collection.name,
'Id': summary.collection.id
}
},
'Run': {
'Stats': {
"Requests" : summary.run.stats.requests,
"Assertions" : summary.run.stats.assertions
},
'Executions': executions,
'Timings' : summary.run.timings
}
});
return result;
}
module.exports = function(newman, options) {
newman.on('beforeDone', function(err, data) {
if (err) { return; }
newman.exports.push({
name: 'newman-reporter-demx',
default: 'summary.json',
path: options.jsonExport,
content: JSON.stringify(createSummary(data.summary))
});
});
};