@@ -25,47 +25,81 @@ class CleanReporter {
2525 . trim ( ) ;
2626
2727 if ( result . status === "passed" ) {
28- logStamp ( `✅ ${ cleanSuite } : ${ testName } ` ) ;
29- } else if ( result . status === "failed" ) {
30- logStamp ( `❌ ${ cleanSuite } : ${ testName } ` ) ;
31-
32- // Extract the most relevant error info
33- const error = result . error || result . errors ?. [ 0 ] ;
34- if ( error ) {
35- let errorMsg = error . message || "Unknown error" ;
36-
37- // Clean up common error patterns to make them more readable
38- if ( errorMsg . includes ( "None of the expected patterns matched" ) ) {
39- const patterns = errorMsg . match ( / p a t t e r n s m a t c h e d [ ^ : ] * : ( [ ^ ` ] + ) / ) ;
40- errorMsg = `AI response timeout - Expected: ${
41- patterns ?. [ 1 ] || "AI response"
42- } `;
43- } else if (
44- errorMsg . includes ( "Timed out" ) &&
45- errorMsg . includes ( "toBeVisible" )
46- ) {
47- const element = errorMsg . match ( / l o c a t o r \( ' ( [ ^ ' ] + ) ' \) / ) ;
48- errorMsg = `Element not found: ${ element ?. [ 1 ] || "UI element" } ` ;
49- } else if ( errorMsg . includes ( "toBeGreaterThan" ) ) {
50- errorMsg = "Expected content not generated (count was 0)" ;
51- }
52-
53- // Show just the key error info
54- console . log ( ` 💥 ${ errorMsg . split ( "\n" ) [ 0 ] } ` ) ;
55-
56- // If it's an AI/API issue, make it clear
57- if (
58- errorMsg . includes ( "AI" ) ||
59- errorMsg . includes ( "patterns" ) ||
60- errorMsg . includes ( "timeout" )
61- ) {
62- console . log ( ` 🔑 Likely cause: AI service down or API key issue` ) ;
63- }
28+ logStamp ( `✅ PASS ${ cleanSuite } : ${ testName } ` ) ;
29+ return ;
30+ }
31+
32+ if ( result . status === "skipped" ) {
33+ console . log ( `⚠️ SKIP ${ cleanSuite } : ${ testName } (skipped)` ) ;
34+ return ;
35+ }
36+
37+ // Handle all failure modes: "failed", "timedOut", "interrupted"
38+ const icon = result . status === "timedOut" ? "⏰ TIMEOUT" : "❌ FAIL" ;
39+ logStamp ( `${ icon } ${ cleanSuite } : ${ testName } ` ) ;
40+
41+ // Extract the most relevant error info
42+ const error = result . error || result . errors ?. [ 0 ] ;
43+ if ( error ) {
44+ let errorMsg = error . message || "Unknown error" ;
45+
46+ // Clean up common error patterns to make them more readable
47+ if ( errorMsg . includes ( "None of the expected patterns matched" ) ) {
48+ const patterns = errorMsg . match ( / p a t t e r n s m a t c h e d [ ^ : ] * : ( [ ^ ` ] + ) / ) ;
49+ errorMsg = `AI response timeout - Expected: ${
50+ patterns ?. [ 1 ] || "AI response"
51+ } `;
52+ } else if (
53+ errorMsg . includes ( "Timed out" ) &&
54+ errorMsg . includes ( "toBeVisible" )
55+ ) {
56+ const element = errorMsg . match ( / l o c a t o r \( ' ( [ ^ ' ] + ) ' \) / ) ;
57+ errorMsg = `Element not found: ${ element ?. [ 1 ] || "UI element" } ` ;
58+ } else if ( errorMsg . includes ( "Test timeout of" ) ) {
59+ errorMsg = errorMsg . split ( "\n" ) [ 0 ] ;
60+ } else if ( errorMsg . includes ( "toBeGreaterThan" ) ) {
61+ errorMsg = "Expected content not generated (count was 0)" ;
62+ }
63+
64+ // Show just the key error info
65+ console . log ( `💥 ERROR: ${ errorMsg . split ( "\n" ) [ 0 ] } ` ) ;
66+
67+ // If it's an AI/API issue, make it clear
68+ if (
69+ errorMsg . includes ( "AI" ) ||
70+ errorMsg . includes ( "patterns" ) ||
71+ errorMsg . includes ( "timeout" )
72+ ) {
73+ console . log ( ` HINT: Likely cause: AI service down or API key issue` ) ;
74+ }
75+ }
76+
77+ // Surface diagnostic output from test-isolation-helper on failure.
78+ // This includes AI State Dump, NetworkError, PageError, and
79+ // BrowserConsole lines that would otherwise be hidden by this reporter.
80+ const diagnosticPrefixes = [
81+ "[AI State Dump]" ,
82+ "[NetworkError]" ,
83+ "[PageError]" ,
84+ "[BrowserConsole]" ,
85+ "[Test Cleanup]" ,
86+ "[User]" ,
87+ "[Assistant]" ,
88+ ] ;
89+ const stdout = ( result . stdout || [ ] )
90+ . map ( ( chunk ) => ( typeof chunk === "string" ? chunk : chunk . toString ( "utf-8" ) ) )
91+ . join ( "" ) ;
92+ const diagnosticLines = stdout
93+ . split ( "\n" )
94+ . filter ( ( line ) => diagnosticPrefixes . some ( ( p ) => line . includes ( p ) ) ) ;
95+ if ( diagnosticLines . length > 0 ) {
96+ console . log ( " --- Diagnostics ---" ) ;
97+ for ( const line of diagnosticLines ) {
98+ console . log ( ` ${ line . trim ( ) } ` ) ;
6499 }
65- console . log ( "" ) ; // Extra spacing after failures
66- } else if ( result . status === "skipped" ) {
67- console . log ( `⏭ ${ cleanSuite } : ${ testName } (skipped)` ) ;
68100 }
101+
102+ console . log ( "" ) ; // Extra spacing after failures
69103 }
70104
71105 onEnd ( result ) {
@@ -75,7 +109,7 @@ class CleanReporter {
75109
76110 if ( ! process . env . CI ) {
77111 console . log (
78- `• Run 'pnpm exec playwright show-report' for detailed HTML report`
112+ `Run 'pnpm exec playwright show-report' for detailed HTML report`
79113 ) ;
80114 }
81115
0 commit comments