@@ -124,25 +124,34 @@ export interface RunJestJsonResult extends RunJestResult {
124124}
125125
126126// https://github.com/nodejs/node/issues/60704
127- function removeLocalStorageWarning ( stream : string ) : string {
127+ function removeLocalStorageWarning ( string : string ) : string {
128128 const nodeNumberWarning = / \( n o d e : \d + \) W a r n i n g : ` - - l o c a l s t o r a g e - f i l e ` / g;
129129 const nodeNumberReplacement = '(node: line) Warning: `--localstorage-file`' ;
130130
131131 const localStorageWarning =
132132 `${ nodeNumberReplacement } was provided without a valid path\n` +
133133 '(Use `node --trace-warnings ...` to show where the warning was created)' ;
134- const localStorageWarningWithNewlines = `\n\n${ localStorageWarning } ` ;
134+ const localStorageWarningWithLeadingNewline = `\n${ localStorageWarning } ` ;
135+ const localStorageWarningWithLeadingNewlines = `\n${ localStorageWarningWithLeadingNewline } ` ;
135136
136- return stream
137+ return string
137138 . replaceAll ( nodeNumberWarning , nodeNumberReplacement )
138- . replaceAll ( localStorageWarningWithNewlines , '' )
139+ . replaceAll ( `${ localStorageWarningWithLeadingNewlines } \n` , '' )
140+ . replaceAll ( localStorageWarningWithLeadingNewlines , '' )
141+ . replaceAll ( `${ localStorageWarningWithLeadingNewline } \n` , '' )
142+ . replaceAll ( localStorageWarningWithLeadingNewline , '' )
143+ . replaceAll ( `${ localStorageWarning } \n` , '' )
139144 . replaceAll ( localStorageWarning , '' ) ;
140145}
141146
142147function normalizeStreamString (
143148 stream : string ,
144149 options : RunJestOptions ,
145150) : string {
151+ if ( stream . length === 0 ) {
152+ return '' ;
153+ }
154+
146155 if ( options . stripAnsi ) stream = stripAnsi ( stream ) ;
147156 stream = normalizeIcons ( stream ) ;
148157 stream = removeLocalStorageWarning ( stream ) ;
0 commit comments