Skip to content

Commit 1768320

Browse files
author
Krystof Woldrich
committed
Add sentry/react-native/playground export and tests
1 parent 6a8f264 commit 1768320

11 files changed

Lines changed: 3194 additions & 70 deletions

File tree

packages/core/playground.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/js/playground';

packages/core/playground.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/js/playground';

packages/core/src/js/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,3 @@ export { FeedbackWidget } from './feedback/FeedbackWidget';
9494
export { showFeedbackWidget, showFeedbackButton, hideFeedbackButton } from './feedback/FeedbackWidgetManager';
9595

9696
export { getDataFromUri } from './wrapper';
97-
98-
export { SentryPlayground as Wizard, withSentryPlayground } from './playground/modal';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { withSentryPlayground } from './modal';

packages/core/src/js/playground/modal.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ import { hi as hiAnimation, bug as bugAnimation, thumbsup as thumbsupAnimation }
2020
import { hi as hiImage, bug as bugImage, thumbsup as thumbsupImage } from './images';
2121
import { nativeCrashExample, tryCatchExample, uncaughtErrorExample } from './examples';
2222

23+
/**
24+
* Wrapper to add Sentry Playground to your application
25+
* to test your Sentry React Native SDK setup.
26+
*
27+
* @example
28+
* ```tsx
29+
* import * as Sentry from '@sentry/react-native';
30+
* import { withSentryPlayground } from '@sentry/react-native/playground';
31+
*
32+
* function App() {
33+
* return <View>...</View>;
34+
* }
35+
*
36+
* export default withSentryPlayground(Sentry.wrap(App), {
37+
* projectId: '123456',
38+
* organizationSlug: 'my-org'
39+
* });
40+
* ```
41+
*/
2342
export const withSentryPlayground = <P extends object>(
2443
Component: React.ComponentType<P>,
2544
options: { projectId?: string; organizationSlug?: string } = {},

packages/core/test/playground/__snapshots__/modal.test.tsx.snap

Lines changed: 3077 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { render } from '@testing-library/react-native';
2+
import * as React from 'react';
3+
import { SentryPlayground } from '../../src/js/playground/modal';
4+
5+
describe('PlaygroundComponent', () => {
6+
afterEach(() => {
7+
jest.clearAllMocks();
8+
});
9+
10+
it('matches the snapshot with no props', () => {
11+
const { toJSON } = render(<SentryPlayground />);
12+
expect(toJSON()).toMatchSnapshot();
13+
});
14+
15+
it('matches the snapshot with project id and organization slug', () => {
16+
const { toJSON } = render(<SentryPlayground projectId="test-project-1234" organizationSlug="test-org-slug-1234" />);
17+
expect(toJSON()).toMatchSnapshot();
18+
});
19+
});

packages/core/tsconfig.build.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"include": [
44
"./src/js/*.ts",
55
"./src/js/*.tsx",
6+
"./src/js/playground/*.ts",
7+
"./src/js/playground/*.tsx",
68
"./src/js/**/*.web.ts",
79
"./src/js/**/*.web.tsx",
810
"./typings/react-native.d.ts"

samples/expo/app/(tabs)/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ import React from 'react';
1010
import * as WebBrowser from 'expo-web-browser';
1111
import { useUpdates } from 'expo-updates';
1212
import { isWeb } from '../../utils/isWeb';
13-
import { Wizard } from '@sentry/react-native';
14-
import { Image } from 'react-native';
1513

1614
const isRunningInExpoGo = Constants.appOwnership === 'expo';
1715

1816
export default function TabOneScreen() {
1917
const { currentlyRunning } = useUpdates();
2018
return (
2119
<View style={styles.container}>
22-
<Wizard />
2320
{/* <Image source={require('../..//hi.gif')} style={{ width: 100, height: 100 }} /> */}
2421
<Sentry.TimeToInitialDisplay record />
2522
<Text>Welcome to Sentry Expo Sample App!</Text>

samples/expo/app/_layout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as Sentry from '@sentry/react-native';
1111
import { LogBox } from 'react-native';
1212
import { isWeb } from '../utils/isWeb';
1313
import * as ImagePicker from 'expo-image-picker';
14+
import { withSentryPlayground } from '@sentry/react-native/playground';
1415

1516
export {
1617
// Catch any errors thrown by the Layout component.
@@ -144,4 +145,9 @@ function RootLayoutNav() {
144145
);
145146
}
146147

148+
// export default withSentryPlayground(Sentry.wrap(RootLayout), {
149+
// projectId: '5428561',
150+
// organizationSlug: 'sentry-sdks',
151+
// });
152+
147153
export default Sentry.wrap(RootLayout);

0 commit comments

Comments
 (0)