Skip to content

Commit 3b1869f

Browse files
committed
also trailing newline
1 parent d6d9b04 commit 3b1869f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

e2e/runJest.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = /\(node:\d+\) Warning: `--localstorage-file`/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

142147
function 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

Comments
 (0)