-
Notifications
You must be signed in to change notification settings - Fork 257
Add error boundary e2e tests in React Native #2590
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
Merged
AnastasiiaSvietlova
merged 13 commits into
next
from
PLAT-13248-error-boundary-e2e-tests
Oct 21, 2025
+60
−0
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
abfa09a
add error boundary e2e test
AnastasiiaSvietlova 17d4cfc
fix lint errors
AnastasiiaSvietlova 23cc736
fix lint
AnastasiiaSvietlova ba94914
add react import
AnastasiiaSvietlova 0e8d86d
add timer for error
AnastasiiaSvietlova a278293
update scenario
AnastasiiaSvietlova 996cdfa
add jsConfig
AnastasiiaSvietlova 397405c
add set timeout
AnastasiiaSvietlova 3071dc5
revert not needed changes
AnastasiiaSvietlova f25be8b
add empty onError callback to prevent app crashing
gingerbenw 40ca68a
add new step in scenario
AnastasiiaSvietlova f32eba0
add metadata to the event
AnastasiiaSvietlova bb8e0c6
fix the event metadata
AnastasiiaSvietlova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...ive/features/fixtures/scenario-launcher/src/scenarios/ReactNativeErrorBoundaryScenario.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Bugsnag from '@bugsnag/react-native' | ||
import * as React from 'react' | ||
import { Text, View } from 'react-native' | ||
import Scenario from './Scenario' | ||
|
||
const onError = (event) => { | ||
// callback will only run for errors caught by boundary | ||
event.addMetadata('errorBoundary', 'caughtByErrorBoundary', true) | ||
event.addMetadata('errorBoundary', 'handlerType', 'react-native-error-boundary') | ||
} | ||
|
||
export class ReactNativeErrorBoundaryScenario extends Scenario { | ||
view () { | ||
const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React) | ||
return ( | ||
<ErrorBoundary FallbackComponent={ErrorView} onError={onError}> | ||
<MainView /> | ||
</ErrorBoundary> | ||
) | ||
} | ||
|
||
run () { | ||
// Error is thrown during render | ||
} | ||
} | ||
|
||
function ErrorView () { | ||
return ( | ||
<View> | ||
<Text>There was an error</Text> | ||
</View> | ||
) | ||
} | ||
|
||
function MainView () { | ||
return ( | ||
<View> | ||
<Text>Hello world {text()}</Text> | ||
</View> | ||
) | ||
} | ||
|
||
const text = function () { | ||
throw new Error('borked') | ||
} |
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
12 changes: 12 additions & 0 deletions
12
test/react-native/features/react-native-error-boundary.feature
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Feature: ReactNative ErrorBoundary support | ||
|
||
Scenario: ErrorBoundary component reports errors | ||
When I run "ReactNativeErrorBoundaryScenario" | ||
And I relaunch the app after a crash | ||
And I configure Bugsnag for "ReactNativeErrorBoundaryScenario" | ||
Then I wait to receive an error | ||
And the exception "errorClass" equals "Error" | ||
And the exception "message" equals "borked" | ||
And the event "metaData.react.componentStack" is not null | ||
And the event "metaData.errorBoundary.caughtByErrorBoundary" is true | ||
And the event "metaData.errorBoundary.handlerType" equals "react-native-error-boundary" |
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.
Uh oh!
There was an error while loading. Please reload this page.