Skip to content

Commit 8c3b1d9

Browse files
committed
fix(snapshot): normalize bare ~ to <HOME> in snapshot output
The tilde replacement only handled ~/path patterns. Add a rule for bare ~ (preceded by whitespace or colon, followed by whitespace or EOL) so that outputs like 'Home: ~' are normalized to 'Home: <HOME>'.
1 parent dd4727b commit 8c3b1d9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/snapshot-tests/normalize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function normalizeSnapshotOutput(text: string): string {
8585
const home = os.homedir();
8686
normalized = normalized.replace(new RegExp(escapeRegex(home), 'g'), '<HOME>');
8787
normalized = normalized.replace(/~\//g, '<HOME>/');
88+
normalized = normalized.replace(/(?<=\s|:)~(?=\s|$)/gm, '<HOME>');
8889

8990
const tmpDir = os.tmpdir();
9091
normalized = normalized.replace(

0 commit comments

Comments
 (0)