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
{{ message }}
Repository navigation
[Bug]: Stack trace paths are mangled and the code frame is missing when the project path contains parentheses #16548
at toBe (/home/me/jest (copy)../../../sum.test.js:3:15)
at Array.forEach (<anonymous>)
at Object.forEach (/home/me/jest (copy)../../../sum.test.js:2:7)
When running without a source-map transform (npx jest --transform="{}"), where the top frame is anonymous (at /home/me/jest (copy)/sum.test.js:3:15), the code frame is also missing completely:
at /home/me/jest (copy)../../../sum.test.js:3:15
at Array.forEach (<anonymous>)
at Object.<anonymous> (/home/me/jest (copy)../../../sum.test.js:2:7)
Additional context
Two causes in packages/jest-message-util/src/index.ts:
formatPath uses /(^\s*at .*?\(?)([^()]+)(:\d+:\d+\)?.*$)/, so the captured path (match[2]) is only the segment after the last ) (/sum.test.js), which path.relative(config.rootDir, match[2]) turns into ../../../sum.test.js and concatenates right after match[1].
getTopFrame calls stack-utilsparseLine, which splits an anonymous frame at /home/me/jest (copy)/sum.test.js:3:15 into function /home/me/jest and non-absolute file copy)/sum.test.js, so formatStackTrace skips rendering the code frame.
Directories like C:\Users\Jane (Work)\... or project (1) hit this. Unchanged on main (7261444).
Thanks for the precise write-up, both causes were exactly where you pointed. I opened #16549 with a fix:
formatPath now first matches frames whose location is an absolute path or file:// URL running to the end of the line, so the path keeps its parentheses. Other frames, including eval ones, still go through the existing regex.
getTopFrame parses anonymous frames like at /a (b)/c.js:1:2 itself instead of going through stack-utils, so the code frame comes back.
I checked it with your reproduction in a jest (copy) directory on Windows: the paths print as sum.test.js:3:15, and with --transform={} the code frame is shown again.
Activity
X6M-Work commentedon Nov 7, 2026
Thanks for the precise write-up, both causes were exactly where you pointed. I opened #16549 with a fix:
formatPathnow first matches frames whose location is an absolute path orfile://URL running to the end of the line, so the path keeps its parentheses. Other frames, includingevalones, still go through the existing regex.getTopFrameparses anonymous frames likeat /a (b)/c.js:1:2itself instead of going throughstack-utils, so the code frame comes back.I checked it with your reproduction in a
jest (copy)directory on Windows: the paths print assum.test.js:3:15, and with--transform={}the code frame is shown again.abraham21587 commentedon Nov 10, 2026
I’d like to work on this
fix(jest-message-util): keep stack paths that contain parentheses intact