@@ -142,6 +142,33 @@ export function lineInformation(result: TestResult): string {
142142 return ` (${ result . file } :${ result . line } )` ;
143143}
144144
145+ function getDiffMessages ( result : TestResult ) : string [ ] {
146+ const diffs = result . diffs ;
147+ const messages : string [ ] = [ ] ;
148+
149+ if ( ! diffs || ! Array . isArray ( diffs ) || diffs . length === 0 ) {
150+ return messages ;
151+ }
152+
153+ diffs . forEach ( ( diffPair : [ string , [ string , string ] ] ) => {
154+ if ( Array . isArray ( diffPair ) && diffPair . length === 2 ) {
155+ const [ _ , [ removed , added ] ] = diffPair ;
156+
157+ if ( removed || added ) {
158+ messages . push ( '; diff:' ) ;
159+ messages . push ( removed ? `- ${ removed } ` : '' ) ;
160+ if ( added ) {
161+ messages . push ( `+ ${ added } ` ) ;
162+ }
163+ }
164+ } else {
165+ console . warn ( 'Invalid diff pair format:' , diffPair ) ;
166+ }
167+ } ) ;
168+
169+ return messages ;
170+ }
171+
145172// Return a detailed message about why a test failed.
146173// If the test passed, return the empty string.
147174// The message contains "comment" lines that are prepended with ;
@@ -173,6 +200,11 @@ export function detailedMessage(result: TestResult): string | undefined {
173200 if ( result . actual ) {
174201 messages . push ( `; actual:\n${ result . actual } ` ) ;
175202 }
203+
204+ const diffMessages = getDiffMessages ( result ) ;
205+ if ( diffMessages . length > 0 ) {
206+ messages . push ( ...diffMessages ) ;
207+ }
176208 }
177209 return messages . length > 0 ? messages . join ( '\n' ) : undefined ;
178210}
0 commit comments