-
Notifications
You must be signed in to change notification settings - Fork 256
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
Changes from 11 commits
abfa09a
17d4cfc
23cc736
ba94914
0e8d86d
a278293
996cdfa
397405c
3071dc5
f25be8b
40ca68a
f32eba0
bb8e0c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| 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 | ||
| } | ||
|
|
||
| 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') | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| @react_error_boundary | ||||||
|
||||||
| Feature: React Error Boundary support | ||||||
|
||||||
| Feature: React Error Boundary support | |
| Feature: ReactNative ErrorBoundary support |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Scenario: basic error boundary usage | |
| Scenario: ErrorBoundary component reports errors |
Uh oh!
There was an error while loading. Please reload this page.