feat: handle line endings in snapshot#15708
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
| const LINE_ENDING_MAPPINGS = [ | ||
| ['\r\n', '\\r\\n'], | ||
| ['\r', '\\r'], | ||
| ['\n', '\\n'], | ||
| ] as const; | ||
|
|
||
| const normalizeTestNameForKey = (testName: string): string => { | ||
| let result = testName; | ||
| for (const [original, escaped] of LINE_ENDING_MAPPINGS) { | ||
| result = result.replaceAll(original, escaped); | ||
| } | ||
| return result; | ||
| }; | ||
|
|
||
| const denormalizeTestNameFromKey = (key: string): string => { | ||
| let result = key; | ||
| for (const [original, escaped] of LINE_ENDING_MAPPINGS) { | ||
| result = result.replaceAll(escaped, original); | ||
| } | ||
| return result; | ||
| }; |
There was a problem hiding this comment.
Could these not just be a single regex?
cpojer
left a comment
There was a problem hiding this comment.
I like it, but we can probably just use one regex each, no?
|
I changed it to replaceAll func |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
resolves #15672
I am not sure whether this is a correct approach for this issue. However, when line ending is explicitly defined in a string content, I think normalizing makes more sense.
Test plan
e2e