Skip to content

Deliberately crash your app. Good for testing crash reporting services.

License

Notifications You must be signed in to change notification settings

Lighthouse-io/react-native-crash-tester

 
 

Repository files navigation

react-native-crash-tester

Deliberately crash your app. Good for testing crash reporting services.

Installation

npm install react-native-crash-tester

or

yarn add react-native-crash-tester

Usage

Trigger a Native Crash

import CrashTester from 'react-native-crash-tester';

CrashTester.nativeCrash();
CrashTester.nativeCrash('Custom message!');

Trigger a JavaScript Crash

import CrashTester from 'react-native-crash-tester';

CrashTester.jsCrash();
CrashTester.jsCrash('Custom message!');

Test a React Error Boundary

import * as React from 'react';
import { Button } from 'react-native';
import { CrashingComponent } from 'react-native-crash-tester';
import ErrorBoundary from './MyErrorBoundary';

function TestComponent() {
  const [shown, setShown] = React.useState(false);

  <ErrorBoundary>
    <Button title="Crash" onPress={() => setShown(true)} />
    {shown && <CrashingComponent />}
  </ErrorBoundary>;
}

You can run the app in ./example to see sample usage.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

Deliberately crash your app. Good for testing crash reporting services.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 43.8%
  • TypeScript 19.9%
  • Objective-C 19.0%
  • JavaScript 8.0%
  • Ruby 7.0%
  • Swift 1.7%
  • C 0.6%