Skip to content

[tests] Add \n in <stack> placeholder for native stacks#35496

Closed
rickhanlonii wants to merge 4 commits intofacebook:mainfrom
rickhanlonii:asserts-stack-2
Closed

[tests] Add \n in <stack> placeholder for native stacks#35496
rickhanlonii wants to merge 4 commits intofacebook:mainfrom
rickhanlonii:asserts-stack-2

Conversation

@rickhanlonii
Copy link
Member

Stacked on #35495


Some of the error messages we asset on add a native javascript stack trace, which would be a pain to add to the messages and maintain. This PR allows you to just add \n in <stack> placeholder to the error message to denote a native stack trace is present in the message.

Note: it was a pain to break this into a stack so the actual impl in consoleMock has some unrelated changes. I'd probably just review the tests for this diff and ignore the changes, I plan on simplifying it and cleaning it up in a later PR.

Update test assertions to include the complete component stack trace
rather than partial stacks. This ensures tests validate the full
owner stack as it would appear in development.
@meta-cla meta-cla bot added the CLA Signed label Jan 12, 2026
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jan 12, 2026
@react-sizebot
Copy link

react-sizebot commented Jan 12, 2026

Comparing: 5aec1b2...f87b7d0

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.16% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 607.60 kB 607.60 kB = 107.53 kB 107.54 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.11% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 666.83 kB 666.83 kB = 117.42 kB 117.42 kB
facebook-www/ReactDOM-prod.classic.js = 692.91 kB 692.91 kB = 121.92 kB 121.92 kB
facebook-www/ReactDOM-prod.modern.js = 683.34 kB 683.34 kB = 120.31 kB 120.31 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against f87b7d0

Add two new placeholders for console error assertions:

1. [Server] - expands to the ANSI escape sequence for server badge
   Instead of: '\u001b[0m\u001b[7m Server \u001b[0mError: message'
   Write: '[Server] Error: message'

2. \n    in <stack> - matches JavaScript Error stack traces
   Instead of matching the full error stack manually
   Write: 'Error: message\n    in <stack>'

The error stack placeholder validates that it's only used for actual
Error stack traces (messages starting with "Error:" that have file:line:col
frames), not for React component stacks.

Also adds validation to catch misuse of these placeholders and provides
helpful error messages guiding developers to the correct usage.
@rickhanlonii
Copy link
Member Author

yeah i'm not fucking with a stack on this anymore, merging into #35497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments