deflake 1.2.29 → 1.2.30
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/cli.js +33 -12
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -256,24 +256,45 @@ async function applyFix(res, loc) {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
function extractRelevantOutput(fullOutput, artifactName) {
|
|
259
|
-
//
|
|
260
|
-
//
|
|
259
|
+
// SMART: Use Playwright's "Error Context:" line to find the EXACT error block for this artifact.
|
|
260
|
+
// Each Playwright failure ends with: "Error Context: test-results/<artifact-name>/error-context.md"
|
|
261
|
+
// We find that line, then walk backwards to capture the full error + stack trace.
|
|
262
|
+
|
|
261
263
|
const lines = fullOutput.split('\n');
|
|
262
|
-
let relevant = [];
|
|
263
|
-
let capturing = false;
|
|
264
264
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
// Find the Error Context line that matches this artifact
|
|
266
|
+
let anchorIdx = -1;
|
|
267
|
+
for (let i = 0; i < lines.length; i++) {
|
|
268
|
+
if (lines[i].includes('Error Context:') && lines[i].includes(artifactName)) {
|
|
269
|
+
anchorIdx = i;
|
|
270
|
+
break;
|
|
268
271
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (anchorIdx === -1) {
|
|
275
|
+
// Fallback: try partial match on artifact name parts
|
|
276
|
+
const nameParts = artifactName.split('-').filter(p => p.length > 3);
|
|
277
|
+
for (let i = 0; i < lines.length; i++) {
|
|
278
|
+
if (lines[i].includes('Error Context:') && nameParts.some(part => lines[i].includes(part))) {
|
|
279
|
+
anchorIdx = i;
|
|
280
|
+
break;
|
|
273
281
|
}
|
|
274
282
|
}
|
|
275
283
|
}
|
|
276
|
-
|
|
284
|
+
|
|
285
|
+
if (anchorIdx === -1) return '';
|
|
286
|
+
|
|
287
|
+
// Walk backwards from anchor to find the start of this error block
|
|
288
|
+
// Error blocks in Playwright start with "N) [chromium] › tests/..."
|
|
289
|
+
let startIdx = anchorIdx;
|
|
290
|
+
for (let i = anchorIdx; i >= 0; i--) {
|
|
291
|
+
if (lines[i].match(/^\s*\d+\)\s+\[/)) {
|
|
292
|
+
startIdx = i;
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return lines.slice(startIdx, anchorIdx + 1).join('\n');
|
|
277
298
|
}
|
|
278
299
|
|
|
279
300
|
function extractLoc(text) {
|