Skip to content

Conversation

@notoriousmango
Copy link
Contributor

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

@netlify
Copy link

netlify bot commented Jun 28, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit eabe417
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/68653fbd9714dd00086a6ce6
😎 Deploy Preview https://deploy-preview-15708--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 28, 2025

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15708 

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15708 

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15708 

create-jest

npm i https://pkg.pr.new/create-jest@15708 

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15708 

expect

npm i https://pkg.pr.new/expect@15708 

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15708 

jest

npm i https://pkg.pr.new/jest@15708 

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15708 

jest-circus

npm i https://pkg.pr.new/jest-circus@15708 

jest-cli

npm i https://pkg.pr.new/jest-cli@15708 

jest-config

npm i https://pkg.pr.new/jest-config@15708 

@jest/console

npm i https://pkg.pr.new/@jest/console@15708 

@jest/core

npm i https://pkg.pr.new/@jest/core@15708 

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15708 

jest-diff

npm i https://pkg.pr.new/jest-diff@15708 

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15708 

jest-each

npm i https://pkg.pr.new/jest-each@15708 

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15708 

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15708 

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15708 

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15708 

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15708 

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15708 

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15708 

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15708 

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15708 

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15708 

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15708 

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15708 

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15708 

jest-mock

npm i https://pkg.pr.new/jest-mock@15708 

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15708 

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15708 

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15708 

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15708 

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15708 

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15708 

jest-runner

npm i https://pkg.pr.new/jest-runner@15708 

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15708 

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15708 

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15708 

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15708 

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15708 

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15708 

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15708 

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15708 

@jest/types

npm i https://pkg.pr.new/@jest/types@15708 

jest-util

npm i https://pkg.pr.new/jest-util@15708 

jest-validate

npm i https://pkg.pr.new/jest-validate@15708 

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15708 

jest-worker

npm i https://pkg.pr.new/jest-worker@15708 

pretty-format

npm i https://pkg.pr.new/pretty-format@15708 

commit: eabe417

Comment on lines 78 to 98
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;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these not just be a single regex?

Copy link
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but we can probably just use one regex each, no?

@notoriousmango
Copy link
Contributor Author

I changed it to replaceAll func

@cpojer cpojer merged commit fceea7a into jestjs:main Jul 2, 2025
76 checks passed
@notoriousmango notoriousmango deleted the 15672 branch July 3, 2025 01:02
@github-actions
Copy link

github-actions bot commented Aug 3, 2025

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants