deflake 1.2.31 → 1.2.33

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 +10 -23
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -116,10 +116,8 @@ async function analyzeAndFix(artifacts, client, argv, capturedOutput = '') {
116
116
  return 0;
117
117
  }
118
118
 
119
- // Debug: verify captured output content
120
- const hasErrorContext = capturedOutput.includes('Error Context:');
121
- const errorContextCount = (capturedOutput.match(/Error Context:/g) || []).length;
122
- console.log(`${C.GRAY}📊 Captured output: ${capturedOutput.length} chars, Error Context lines: ${errorContextCount}, has 'at ': ${capturedOutput.includes(' at ')}${C.RESET}`);
119
+ // Strip ANSI escape codes from captured output — they break regex matching
120
+ const cleanOutput = capturedOutput.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '');
123
121
 
124
122
  console.log(`${C.BRIGHT}🔍 Analyzing ${artifacts.length} failure(s)...${C.RESET}\n`);
125
123
  let count = 0;
@@ -133,10 +131,11 @@ async function analyzeAndFix(artifacts, client, argv, capturedOutput = '') {
133
131
  let loc = extractLoc(content);
134
132
  let locSource = 'error-context.md';
135
133
 
136
- if (!loc && capturedOutput) {
134
+ if (!loc && cleanOutput) {
137
135
  // Extract the relevant section from captured output for this artifact
138
- const relevantOutput = extractRelevantOutput(capturedOutput, art.name);
139
- loc = extractLoc(relevantOutput || capturedOutput);
136
+ const relevantOutput = extractRelevantOutput(cleanOutput, art.name);
137
+ console.log(` ${C.GRAY}🔬 Relevant output: ${relevantOutput.length} chars for artifact${C.RESET}`);
138
+ loc = extractLoc(relevantOutput || cleanOutput);
140
139
  locSource = 'console output';
141
140
  }
142
141
 
@@ -262,13 +261,9 @@ async function applyFix(res, loc) {
262
261
  }
263
262
 
264
263
  function extractRelevantOutput(fullOutput, artifactName) {
265
- // SMART: Use Playwright's "Error Context:" line to find the EXACT error block for this artifact.
266
- // Each Playwright failure ends with: "Error Context: test-results/<artifact-name>/error-context.md"
267
- // We find that line, then walk backwards to capture the full error + stack trace.
268
-
264
+ // Find the Error Context line for this artifact, then grab 30 lines before it
269
265
  const lines = fullOutput.split('\n');
270
266
 
271
- // Find the Error Context line that matches this artifact
272
267
  let anchorIdx = -1;
273
268
  for (let i = 0; i < lines.length; i++) {
274
269
  if (lines[i].includes('Error Context:') && lines[i].includes(artifactName)) {
@@ -278,7 +273,7 @@ function extractRelevantOutput(fullOutput, artifactName) {
278
273
  }
279
274
 
280
275
  if (anchorIdx === -1) {
281
- // Fallback: try partial match on artifact name parts
276
+ // Fallback: partial match on artifact name parts
282
277
  const nameParts = artifactName.split('-').filter(p => p.length > 3);
283
278
  for (let i = 0; i < lines.length; i++) {
284
279
  if (lines[i].includes('Error Context:') && nameParts.some(part => lines[i].includes(part))) {
@@ -290,16 +285,8 @@ function extractRelevantOutput(fullOutput, artifactName) {
290
285
 
291
286
  if (anchorIdx === -1) return '';
292
287
 
293
- // Walk backwards from anchor to find the start of this error block
294
- // Error blocks in Playwright start with "N) [chromium] › tests/..."
295
- let startIdx = anchorIdx;
296
- for (let i = anchorIdx; i >= 0; i--) {
297
- if (lines[i].match(/^\s*\d+\)\s+\[/)) {
298
- startIdx = i;
299
- break;
300
- }
301
- }
302
-
288
+ // Grab 30 lines before the anchor — guaranteed to include the full stack trace
289
+ const startIdx = Math.max(0, anchorIdx - 30);
303
290
  return lines.slice(startIdx, anchorIdx + 1).join('\n');
304
291
  }
305
292
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deflake",
3
- "version": "1.2.31",
3
+ "version": "1.2.33",
4
4
  "description": "AI-powered self-healing tool for Playwright, Cypress, and WebdriverIO tests.",
5
5
  "main": "client.js",
6
6
  "bin": {