Skip to content

Conversation

@rickhanlonii
Copy link
Member

Stacked on #35497


Now that the assert helpers require a component stack, we don't need the {withoutStack: true} option.

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.
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.
The withoutStack option allowed tests to skip component stack
validation in assertConsoleErrorDev and assertConsoleWarnDev. This
encouraged tests to be less precise than they should be. By removing
this option, all tests must now include the expected component stack
in their assertions.

Added runtime error when withoutStack is used to help identify any
remaining usages. Updated all test files to remove withoutStack usage.
@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: 4a3d993...ba8792b

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.11% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 608.03 kB 608.03 kB = 107.61 kB 107.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 667.26 kB 667.26 kB = 117.51 kB 117.51 kB
facebook-www/ReactDOM-prod.classic.js = 693.38 kB 693.38 kB = 122.00 kB 122.00 kB
facebook-www/ReactDOM-prod.modern.js = 683.76 kB 683.76 kB = 120.40 kB 120.40 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against ba8792b

@rickhanlonii rickhanlonii changed the title [tests] remove withoutStatck from assertConsole helpers [WIP] [tests] remove withoutStatck from assertConsole helpers Jan 12, 2026
# Conflicts:
#	packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js
#	packages/internal-test-utils/consoleMock.js
#	packages/react/src/__tests__/ReactChildren-test.js
#	packages/react/src/__tests__/createReactClassIntegration-test.js
#	packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js
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