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.
Files changed (2) hide show
  1. package/cli.js +33 -12
  2. 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
- // Extract error sections from captured console output
260
- // Covers: Playwright, Cypress, WebdriverIO stack traces
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
- for (const line of lines) {
266
- if (line.includes('Error:') || line.includes('at ') || line.includes('Failing:')) {
267
- capturing = true;
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
- if (capturing) {
270
- relevant.push(line);
271
- if (line.includes('Error Context:') || (relevant.length > 30 && line.trim() === '')) {
272
- capturing = false;
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
- return relevant.join('\n');
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deflake",
3
- "version": "1.2.29",
3
+ "version": "1.2.30",
4
4
  "description": "AI-powered self-healing tool for Playwright, Cypress, and WebdriverIO tests.",
5
5
  "main": "client.js",
6
6
  "bin": {