-
Notifications
You must be signed in to change notification settings - Fork 0
/
computation.js
46 lines (44 loc) · 1.17 KB
/
computation.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
function computeResult(mutations, threshold) {
const count = mutations.length;
const killed = mutations.filter(
(mutation) => mutation.status === 'KILLED'
).length;
const survived = mutations.filter(
(mutation) => mutation.status === 'SURVIVED'
).length;
const noCoverage = mutations.filter(
(mutation) => mutation.status === 'NO_COVERAGE'
).length;
let testStrength;
if (count - noCoverage === 0) {
testStrength = 0;
} else {
testStrength = Math.round((killed / (count - noCoverage)) * 100);
}
const pass = testStrength >= threshold;
const mutationsDetails = mutations
.filter((mutation) => mutation.detected === false)
.map((mutation) => {
return {
file: mutation.sourceFile,
class: mutation.mutatedClass,
method: mutation.mutatedMethod,
line: mutation.lineNumber,
status: mutation.status,
info: mutation.description,
};
});
return {
count: count,
killed: killed,
survived: survived,
noCoverage: noCoverage,
testStrength: testStrength,
threshold: threshold,
pass: pass,
mutations: mutationsDetails,
};
}
module.exports = {
computeResult,
};