react-native-crash-tester
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.3
    598
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.3
    598
  • 0.2.2
    124
  • 0.2.1
    0
  • 0.2.0
    0

Package Sidebar

Install

npm i react-native-crash-tester

Weekly Downloads

563

Version

0.2.3

License

MIT

Unpacked Size

42 kB

Total Files

28

Last publish

Collaborators

  • chrishenderson