jest-test-lineage-reporter 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -0
- package/bin/jest-lineage.js +20 -0
- package/package.json +14 -5
- package/src/MutationTester.js +1154 -0
- package/src/__tests__/assertion-test.test.ts +59 -0
- package/src/__tests__/calculator.test.ts +30 -0
- package/src/__tests__/depth-example.test.ts +237 -0
- package/src/__tests__/gc-pressure-example.test.ts +169 -0
- package/src/__tests__/performance-example.test.ts +83 -0
- package/src/__tests__/quality-example.test.ts +122 -0
- package/src/__tests__/survived-mutations-example.test.ts +32 -0
- package/src/__tests__/truly-weak-example.test.ts +90 -0
- package/src/__tests__/weak-test-example.test.ts +222 -0
- package/src/babel-plugin-mutation-tester.js +402 -0
- package/src/calculator.ts +12 -0
- package/src/cli/commands/analyze.js +91 -0
- package/src/cli/commands/mutate.js +89 -0
- package/src/cli/commands/query.js +107 -0
- package/src/cli/commands/report.js +65 -0
- package/src/cli/commands/test.js +56 -0
- package/src/cli/index.js +89 -0
- package/src/cli/utils/config-loader.js +114 -0
- package/src/cli/utils/data-loader.js +118 -0
- package/src/cli/utils/jest-runner.js +105 -0
- package/src/cli/utils/output-formatter.js +126 -0
- package/src/depth-example.ts +66 -0
- package/src/gc-pressure-example.ts +158 -0
- package/src/global.d.ts +7 -0
- package/src/mcp/server.js +469 -0
- package/src/performance-example.ts +82 -0
- package/src/quality-example.ts +79 -0
- package/src/survived-mutations-example.ts +19 -0
- package/src/truly-weak-example.ts +37 -0
- package/src/weak-test-example.ts +91 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { demonstrateSurvivedMutations, anotherWeakFunction } from '../survived-mutations-example';
|
|
2
|
+
|
|
3
|
+
describe('Survived Mutations Example', () => {
|
|
4
|
+
// This test is intentionally terrible to demonstrate survived mutations
|
|
5
|
+
|
|
6
|
+
describe('demonstrateSurvivedMutations', () => {
|
|
7
|
+
it('should just call the function', () => {
|
|
8
|
+
// This test literally does NOTHING except call the function
|
|
9
|
+
// No assertions whatsoever!
|
|
10
|
+
|
|
11
|
+
demonstrateSurvivedMutations(42); // Covers input === 42, return 100
|
|
12
|
+
demonstrateSurvivedMutations(60); // Covers input > 50, return input * 2
|
|
13
|
+
demonstrateSurvivedMutations(5); // Covers default case, return input + 10
|
|
14
|
+
|
|
15
|
+
// NO EXPECTATIONS AT ALL!
|
|
16
|
+
// This means ALL mutations will survive because we don't check anything
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('anotherWeakFunction', () => {
|
|
21
|
+
it('should execute the function', () => {
|
|
22
|
+
// This test calls the function but makes NO assertions!
|
|
23
|
+
|
|
24
|
+
anotherWeakFunction(10, 5); // Covers x > y, return true
|
|
25
|
+
anotherWeakFunction(3, 8); // Covers x <= y, return false
|
|
26
|
+
|
|
27
|
+
// NO EXPECTATIONS AT ALL!
|
|
28
|
+
// return true -> return false: SURVIVES
|
|
29
|
+
// return false -> return true: SURVIVES
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { definitelyWillSurvive, anotherSurvivor, booleanSurvivor, guaranteedSurvivor } from '../truly-weak-example';
|
|
2
|
+
|
|
3
|
+
describe('Truly Weak Example - Guaranteed Survived Mutations', () => {
|
|
4
|
+
|
|
5
|
+
describe('definitelyWillSurvive', () => {
|
|
6
|
+
it('should just execute', () => {
|
|
7
|
+
// This test literally does NOTHING except call the function
|
|
8
|
+
// It covers all branches but validates NOTHING
|
|
9
|
+
|
|
10
|
+
definitelyWillSurvive(5); // Covers x === 5, return 42
|
|
11
|
+
definitelyWillSurvive(15); // Covers x > 10, return x + 100
|
|
12
|
+
definitelyWillSurvive(3); // Covers default case, return x * 2
|
|
13
|
+
|
|
14
|
+
// NO ASSERTIONS WHATSOEVER!
|
|
15
|
+
// ALL mutations will survive:
|
|
16
|
+
// return 42 -> return 0: SURVIVES
|
|
17
|
+
// return 42 -> return 1: SURVIVES
|
|
18
|
+
// x + 100 -> x - 100: SURVIVES
|
|
19
|
+
// x + 100 -> x * 100: SURVIVES
|
|
20
|
+
// x * 2 -> x + 2: SURVIVES
|
|
21
|
+
// x * 2 -> x - 2: SURVIVES
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('anotherSurvivor', () => {
|
|
26
|
+
it('should execute without any validation', () => {
|
|
27
|
+
// This test covers all lines but checks NOTHING
|
|
28
|
+
|
|
29
|
+
anotherSurvivor(30, 25); // Covers sum > 50, return sum - 10
|
|
30
|
+
anotherSurvivor(10, 5); // Covers sum <= 50, return sum / 2
|
|
31
|
+
|
|
32
|
+
// NO EXPECTATIONS!
|
|
33
|
+
// Mutations that will survive:
|
|
34
|
+
// a + b -> a - b: SURVIVES
|
|
35
|
+
// a + b -> a * b: SURVIVES
|
|
36
|
+
// sum > 50 -> sum < 50: SURVIVES
|
|
37
|
+
// sum - 10 -> sum + 10: SURVIVES
|
|
38
|
+
// sum / 2 -> sum * 2: SURVIVES
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('booleanSurvivor', () => {
|
|
43
|
+
it('should call the function', () => {
|
|
44
|
+
// This test calls the function but ignores the result completely
|
|
45
|
+
|
|
46
|
+
booleanSurvivor(5); // Covers x > 0, return true
|
|
47
|
+
booleanSurvivor(-3); // Covers x <= 0, return false
|
|
48
|
+
|
|
49
|
+
// NO VALIDATION OF BOOLEAN RESULTS!
|
|
50
|
+
// Mutations that will survive:
|
|
51
|
+
// x > 0 -> x < 0: SURVIVES
|
|
52
|
+
// x > 0 -> x >= 0: SURVIVES
|
|
53
|
+
// return true -> return false: SURVIVES
|
|
54
|
+
// return false -> return true: SURVIVES
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('guaranteedSurvivor', () => {
|
|
59
|
+
it('should execute without any validation whatsoever', () => {
|
|
60
|
+
// This test is designed to be completely useless
|
|
61
|
+
// It catches ALL exceptions and validates NOTHING
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
guaranteedSurvivor(10); // Should return 100, but we don't check
|
|
65
|
+
guaranteedSurvivor(20); // Should return 200, but we don't check
|
|
66
|
+
guaranteedSurvivor(5); // Should return 10, but we don't check
|
|
67
|
+
guaranteedSurvivor(-1); // Should return 4, but we don't check
|
|
68
|
+
} catch (e) {
|
|
69
|
+
// Even if mutations cause errors, we ignore them!
|
|
70
|
+
// This ensures mutations that change behavior but don't crash will survive
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// NO ASSERTIONS AT ALL!
|
|
74
|
+
// ALL mutations will survive because:
|
|
75
|
+
// 1. We don't check return values
|
|
76
|
+
// 2. We catch all exceptions
|
|
77
|
+
// 3. We have no expectations
|
|
78
|
+
//
|
|
79
|
+
// Expected survived mutations:
|
|
80
|
+
// input === 10 -> input !== 10: SURVIVES
|
|
81
|
+
// input === 10 -> input > 10: SURVIVES
|
|
82
|
+
// result = 100 -> result = 0: SURVIVES
|
|
83
|
+
// result = 100 -> result = 1: SURVIVES
|
|
84
|
+
// input === 20 -> input !== 20: SURVIVES
|
|
85
|
+
// result = 200 -> result = 0: SURVIVES
|
|
86
|
+
// input + 5 -> input - 5: SURVIVES
|
|
87
|
+
// input + 5 -> input * 5: SURVIVES
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import {
|
|
2
|
+
simpleAdd,
|
|
3
|
+
complexLogic,
|
|
4
|
+
boundaryCheck,
|
|
5
|
+
logicalOperations,
|
|
6
|
+
mathOperations,
|
|
7
|
+
stringOperations,
|
|
8
|
+
incrementOperations,
|
|
9
|
+
subtleBugFunction,
|
|
10
|
+
reallyWeakFunction,
|
|
11
|
+
guaranteedSurvivedMutations
|
|
12
|
+
} from '../weak-test-example';
|
|
13
|
+
|
|
14
|
+
describe('Weak Test Examples - Some mutations will survive', () => {
|
|
15
|
+
|
|
16
|
+
// GOOD TEST - should kill mutations
|
|
17
|
+
describe('simpleAdd', () => {
|
|
18
|
+
it('should add two positive numbers', () => {
|
|
19
|
+
expect(simpleAdd(2, 3)).toBe(5);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should add negative numbers', () => {
|
|
23
|
+
expect(simpleAdd(-2, -3)).toBe(-5);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// WEAK TEST - missing edge cases, mutations may survive
|
|
28
|
+
describe('complexLogic', () => {
|
|
29
|
+
it('should handle basic case', () => {
|
|
30
|
+
expect(complexLogic(5, 3)).toBe(8); // Only tests the x + y path
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should handle large numbers but with weak assertion', () => {
|
|
34
|
+
const result = complexLogic(15, 5);
|
|
35
|
+
expect(typeof result).toBe('number'); // Very weak! Doesn't check actual value
|
|
36
|
+
// This covers x > 10 path but doesn't verify x * 2 logic
|
|
37
|
+
// Mutations like * to / will survive!
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should handle negative numbers but with weak assertion', () => {
|
|
41
|
+
const result = complexLogic(-5, 10);
|
|
42
|
+
expect(result).toBeGreaterThanOrEqual(0); // Weak! Doesn't check exact value
|
|
43
|
+
// This covers x < 0 path but doesn't verify return 0 logic
|
|
44
|
+
// Mutations like return 0 to return 1 will survive!
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// WEAK TEST - doesn't test boundary conditions properly
|
|
49
|
+
describe('boundaryCheck', () => {
|
|
50
|
+
it('should return medium for normal values', () => {
|
|
51
|
+
expect(boundaryCheck(50)).toBe("medium");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should handle high values but with weak assertion', () => {
|
|
55
|
+
const result = boundaryCheck(150);
|
|
56
|
+
expect(typeof result).toBe('string'); // Weak! Doesn't check actual value
|
|
57
|
+
// This covers >= 100 path but doesn't verify "high" result
|
|
58
|
+
// Mutations like >= to > will survive!
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should handle low values but with weak assertion', () => {
|
|
62
|
+
const result = boundaryCheck(-10);
|
|
63
|
+
expect(result.length).toBeGreaterThan(0); // Weak! Doesn't check actual value
|
|
64
|
+
// This covers <= 0 path but doesn't verify "low" result
|
|
65
|
+
// Mutations like <= to < will survive!
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// WEAK TEST - doesn't test all logical combinations
|
|
70
|
+
describe('logicalOperations', () => {
|
|
71
|
+
it('should handle true and true', () => {
|
|
72
|
+
expect(logicalOperations(true, true)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should handle other combinations but with weak assertions', () => {
|
|
76
|
+
const result1 = logicalOperations(true, false);
|
|
77
|
+
const result2 = logicalOperations(false, true);
|
|
78
|
+
const result3 = logicalOperations(false, false);
|
|
79
|
+
|
|
80
|
+
// Very weak assertions - just check they return booleans!
|
|
81
|
+
expect(typeof result1).toBe('boolean');
|
|
82
|
+
expect(typeof result2).toBe('boolean');
|
|
83
|
+
expect(typeof result3).toBe('boolean');
|
|
84
|
+
|
|
85
|
+
// This covers all logical paths but doesn't verify correct logic
|
|
86
|
+
// Mutations like && to ||, || to &&, !a to a will survive!
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// WEAK TEST - doesn't verify the actual math
|
|
91
|
+
describe('mathOperations', () => {
|
|
92
|
+
it('should return a number', () => {
|
|
93
|
+
const result = mathOperations(10);
|
|
94
|
+
expect(typeof result).toBe('number'); // Very weak assertion!
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should not throw errors', () => {
|
|
98
|
+
// This test covers the lines but doesn't validate the math at all!
|
|
99
|
+
expect(() => {
|
|
100
|
+
mathOperations(5);
|
|
101
|
+
mathOperations(0);
|
|
102
|
+
mathOperations(-3);
|
|
103
|
+
}).not.toThrow();
|
|
104
|
+
|
|
105
|
+
// This covers all the math operation lines but mutations will survive
|
|
106
|
+
// because we're not checking the actual results!
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// WEAK TEST - incomplete string testing
|
|
111
|
+
describe('stringOperations', () => {
|
|
112
|
+
it('should handle non-empty strings', () => {
|
|
113
|
+
const result = stringOperations("hello");
|
|
114
|
+
expect(typeof result).toBe('string'); // Weak assertion
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Missing tests for empty string, boundary lengths
|
|
118
|
+
// String comparison mutations will survive
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// WEAK TEST - doesn't verify increment behavior
|
|
122
|
+
describe('incrementOperations', () => {
|
|
123
|
+
it('should return a number', () => {
|
|
124
|
+
const result = incrementOperations(5);
|
|
125
|
+
expect(result).toBeGreaterThan(0); // Very weak assertion
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should handle edge cases but with wrong expectations', () => {
|
|
129
|
+
// This test covers the lines but has completely wrong logic!
|
|
130
|
+
const result1 = incrementOperations(10);
|
|
131
|
+
const result2 = incrementOperations(15);
|
|
132
|
+
|
|
133
|
+
// These assertions are so generic that mutations will survive
|
|
134
|
+
expect(result1).toBeDefined();
|
|
135
|
+
expect(result2).toBeDefined();
|
|
136
|
+
expect(typeof result1).toBe('number');
|
|
137
|
+
expect(typeof result2).toBe('number');
|
|
138
|
+
|
|
139
|
+
// This covers the increment/decrement logic but doesn't validate it!
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// TERRIBLE TEST - covers lines but doesn't validate behavior at all
|
|
144
|
+
describe('subtleBugFunction', () => {
|
|
145
|
+
it('should execute without errors', () => {
|
|
146
|
+
// This test covers all branches but validates NOTHING!
|
|
147
|
+
let result1, result2, result3;
|
|
148
|
+
|
|
149
|
+
expect(() => {
|
|
150
|
+
result1 = subtleBugFunction(0, 5); // Covers x === 0 branch
|
|
151
|
+
result2 = subtleBugFunction(3, 2); // Covers x > 0 branch
|
|
152
|
+
result3 = subtleBugFunction(-1, 4); // Covers x < 0 branch
|
|
153
|
+
}).not.toThrow();
|
|
154
|
+
|
|
155
|
+
// These assertions are completely useless!
|
|
156
|
+
expect(result1).toBeDefined();
|
|
157
|
+
expect(result2).toBeDefined();
|
|
158
|
+
expect(result3).toBeDefined();
|
|
159
|
+
|
|
160
|
+
// ALL mutations will survive because we don't check actual values!
|
|
161
|
+
// return 1 -> return 0: SURVIVES (we don't check result1 === 1)
|
|
162
|
+
// x + y -> x - y: SURVIVES (we don't check result2 === 5)
|
|
163
|
+
// x - y -> x + y: SURVIVES (we don't check result3 === -5)
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// ABSOLUTELY TERRIBLE TEST - will definitely have survived mutations
|
|
168
|
+
describe('reallyWeakFunction', () => {
|
|
169
|
+
it('should just run without throwing errors', () => {
|
|
170
|
+
// This test only checks that the function doesn't crash!
|
|
171
|
+
// It covers all lines but validates NOTHING about the logic
|
|
172
|
+
|
|
173
|
+
let result1, result2, result3;
|
|
174
|
+
|
|
175
|
+
// Execute the function to cover the lines
|
|
176
|
+
expect(() => {
|
|
177
|
+
result1 = reallyWeakFunction(5, 10); // Covers a * b, result > 100 (false), return result - 5
|
|
178
|
+
result2 = reallyWeakFunction(15, 8); // Covers a * b, result > 100 (true), return result + 10
|
|
179
|
+
result3 = reallyWeakFunction(2, 3); // Covers a * b, result > 100 (false), return result - 5
|
|
180
|
+
}).not.toThrow();
|
|
181
|
+
|
|
182
|
+
// These assertions are completely useless for catching mutations!
|
|
183
|
+
expect(result1).toBeDefined(); // Doesn't check if result1 === 45
|
|
184
|
+
expect(result2).toBeDefined(); // Doesn't check if result2 === 130
|
|
185
|
+
expect(result3).toBeDefined(); // Doesn't check if result3 === 1
|
|
186
|
+
|
|
187
|
+
// MUTATIONS THAT WILL SURVIVE:
|
|
188
|
+
// a * b -> a + b: SURVIVES (we don't check actual calculation)
|
|
189
|
+
// a * b -> a - b: SURVIVES (we don't check actual calculation)
|
|
190
|
+
// a * b -> a / b: SURVIVES (we don't check actual calculation)
|
|
191
|
+
// result > 100 -> result < 100: SURVIVES (we don't check branching logic)
|
|
192
|
+
// result > 100 -> result >= 100: SURVIVES (we don't check branching logic)
|
|
193
|
+
// result + 10 -> result - 10: SURVIVES (we don't check return values)
|
|
194
|
+
// result - 5 -> result + 5: SURVIVES (we don't check return values)
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// ABSOLUTELY USELESS TEST - will definitely have survived mutations
|
|
199
|
+
describe('guaranteedSurvivedMutations', () => {
|
|
200
|
+
it('should exist as a function', () => {
|
|
201
|
+
// This test is so useless it only checks the function exists!
|
|
202
|
+
expect(typeof guaranteedSurvivedMutations).toBe('function');
|
|
203
|
+
|
|
204
|
+
// We call the function but don't check ANY return values
|
|
205
|
+
guaranteedSurvivedMutations(5); // Covers x === 5 branch, return 42
|
|
206
|
+
guaranteedSurvivedMutations(15); // Covers x > 10 branch, return x * 2
|
|
207
|
+
guaranteedSurvivedMutations(3); // Covers default branch, return x + 1
|
|
208
|
+
|
|
209
|
+
// NO ASSERTIONS ON RETURN VALUES!
|
|
210
|
+
// This means ALL mutations will survive:
|
|
211
|
+
// x === 5 -> x !== 5: SURVIVES (we don't check the condition)
|
|
212
|
+
// x === 5 -> x > 5: SURVIVES (we don't check the condition)
|
|
213
|
+
// return 42 -> return 0: SURVIVES (we don't check return value)
|
|
214
|
+
// return 42 -> return 1: SURVIVES (we don't check return value)
|
|
215
|
+
// x > 10 -> x < 10: SURVIVES (we don't check the condition)
|
|
216
|
+
// x * 2 -> x + 2: SURVIVES (we don't check return value)
|
|
217
|
+
// x * 2 -> x - 2: SURVIVES (we don't check return value)
|
|
218
|
+
// x + 1 -> x - 1: SURVIVES (we don't check return value)
|
|
219
|
+
// x + 1 -> x * 1: SURVIVES (we don't check return value)
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|