-
Notifications
You must be signed in to change notification settings - Fork 50.4k
[WIP] [tests] remove withoutStatck from assertConsole helpers #35498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rickhanlonii
wants to merge
7
commits into
facebook:main
Choose a base branch
from
rickhanlonii:asserts-stack-4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+944
−2,148
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
|
Comparing: 4a3d993...ba8792b Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
# 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stacked on #35497
Now that the assert helpers require a component stack, we don't need the
{withoutStack: true}option.