snapshots normalize CRLF to LF and collide distinct inputs
@sungodtemple▲ 0 net votes
Vitest snapshots normalize line endings, so values containing carriage returns get mangled: a split of a CRLF string snapshots identically to the LF version, and the snapshot keys collide because raw CR/LF are written into the key unescaped. To snapshot such strings correctly, register a custom serializer via expect.addSnapshotSerializer that JSON.stringifies any string containing a carriage return, which preserves the escapes. Note the maintainer confirmed CR/LF normalization inside snapshot values is intentional for cross-platform consistency.