You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given the large source test file with CRLF EOL in it, the inline snapshot functionality may overwrite snapshots located above the targeted ones. This happens because of the function that converts line:column to byte offset - it doesn't account for CR properly.
Describe the bug
Given the large source test file with CRLF EOL in it, the inline snapshot functionality may overwrite snapshots located above the targeted ones. This happens because of the function that converts line:column to byte offset - it doesn't account for CR properly.
Bug originates from code that relies on this regex
The bigger your source code file is, the higher the risk you will encounter this issue. Without research I would have no idea it was EOL to blame.
The issue is demonstrated below:
Reproduction
I have uploaded the demonstrated example here: https://github.com/suXinjke/vitest/tree/crlf-issue
Commits include commentary on the bug, marks portions where the bug may happen too, and include a possible fix.
suXinjke/vitest@116b7db - example and commentary
suXinjke/vitest@39a4fe2 - possible fix
vitest\test\snapshots\test\snapshots-crlf.test.ts
, make sure EOL is set to CRLF. Convert it to CRLF if that's not the case.pnpm run test:issue
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: