Skip to content
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

feat: Add support for React error handlers #1354

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Aug 28, 2024

What:

Alternate to #1333

Adds support for onRecoverableError and onCaughtError (React 19 only)

onUncaughtError is not supported yet because there's no use. The render would throw anyway. We're likely going to change that though in React.

Why:

This allows test setups that fail on console errors to silence specific, expected errors in their tests.
Especially onCaughtError will simplify testing of error boundaries since it will disable React's default console.error + window.onError dispatch (see docs I'll add soon)

How:

Forward mentioned options to React's createRoot call.

Checklist:

Copy link

codesandbox-ci bot commented Aug 28, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9a64089:

Sandbox Source
react-testing-library-examples Configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant