Skip to content

Commit b75af25

Browse files
Merge 0dbd3dc into 9d4c63a
2 parents 9d4c63a + 0dbd3dc commit b75af25

File tree

12 files changed

+181
-31
lines changed

12 files changed

+181
-31
lines changed

.github/workflows/sample-application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ jobs:
209209
rn-architecture: 'new'
210210
ios-use-frameworks: 'no-frameworks'
211211
build-type: 'production'
212-
test-command: 'yarn test-ios'
212+
test-command: 'yarn test-ios-manual'
213213

214214
- job-name: 'Test Android Release Manual Init'
215215
platform: android

samples/react-native/.detoxrc.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,26 @@ module.exports = {
4444
},
4545
},
4646
},
47-
'ci.sim': {
47+
'ci.sim.auto': {
4848
device: 'ci.simulator',
4949
app: 'ci.ios',
5050
testRunner: {
5151
args: {
5252
$0: 'jest',
53-
config: 'e2e/jest.config.ios.js',
53+
config: 'e2e/jest.config.ios.auto.js',
54+
},
55+
jest: {
56+
setupTimeout: 120000,
57+
},
58+
},
59+
},
60+
'ci.sim.manual': {
61+
device: 'ci.simulator',
62+
app: 'ci.ios',
63+
testRunner: {
64+
args: {
65+
$0: 'jest',
66+
config: 'e2e/jest.config.ios.manual.js',
5467
},
5568
jest: {
5669
setupTimeout: 120000,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { describe, it, beforeAll, expect, afterAll } from '@jest/globals';
2+
import { Envelope, EventItem } from '@sentry/core';
3+
import { device } from 'detox';
4+
import {
5+
createSentryServer,
6+
containingEvent,
7+
} from './utils/mockedSentryServer';
8+
import { getItemOfTypeFrom } from './utils/event';
9+
10+
describe('Capture app start crash', () => {
11+
let sentryServer = createSentryServer();
12+
sentryServer.start();
13+
14+
let envelope: Envelope;
15+
16+
beforeAll(async () => {
17+
const launchConfig = {
18+
launchArgs: {
19+
0: '--sentry-crash-on-start',
20+
},
21+
};
22+
23+
const envelopePromise = sentryServer.waitForEnvelope(containingEvent);
24+
25+
device.launchApp(launchConfig);
26+
device.launchApp(launchConfig); // This launch sends the crash event before the app crashes again
27+
28+
envelope = await envelopePromise;
29+
});
30+
31+
afterAll(async () => {
32+
await sentryServer.close();
33+
});
34+
35+
it('envelope contains sdk metadata', async () => {
36+
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');
37+
38+
expect(item).toEqual([
39+
{
40+
length: expect.any(Number),
41+
type: 'event',
42+
},
43+
expect.objectContaining({
44+
platform: 'cocoa',
45+
sdk: {
46+
features: [],
47+
integrations: [
48+
'SessionReplay',
49+
'WatchdogTerminationTracking',
50+
'Screenshot',
51+
'Crash',
52+
'ANRTracking',
53+
'ViewHierarchy',
54+
'AutoBreadcrumbTracking',
55+
'AutoSessionTracking',
56+
'NetworkTracking',
57+
'AppStartTracking',
58+
'FramesTracking',
59+
],
60+
name: 'sentry.cocoa.react-native',
61+
packages: [
62+
{
63+
name: 'cocoapods:getsentry/sentry.cocoa.react-native',
64+
version: expect.any(String),
65+
},
66+
{
67+
name: 'npm:@sentry/react-native',
68+
version: expect.any(String),
69+
},
70+
],
71+
version: expect.any(String),
72+
},
73+
tags: {
74+
'event.environment': 'native',
75+
'event.origin': 'ios',
76+
},
77+
}),
78+
]);
79+
});
80+
81+
it('envelope contains the expected exception', async () => {
82+
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');
83+
84+
expect(item).toEqual([
85+
{
86+
length: expect.any(Number),
87+
type: 'event',
88+
},
89+
expect.objectContaining({
90+
exception: {
91+
values: expect.arrayContaining([
92+
expect.objectContaining({
93+
mechanism: expect.objectContaining({
94+
handled: false,
95+
meta: {
96+
mach_exception: {
97+
code: 0,
98+
exception: 10,
99+
name: 'EXC_CRASH',
100+
subcode: 0,
101+
},
102+
signal: {
103+
code: 0,
104+
name: 'SIGABRT',
105+
number: 6,
106+
},
107+
},
108+
type: 'nsexception',
109+
}),
110+
stacktrace: expect.objectContaining({
111+
frames: expect.any(Array),
112+
}),
113+
type: 'CrashOnStart',
114+
value: 'This was intentional test crash before JS started.',
115+
}),
116+
]),
117+
},
118+
}),
119+
]);
120+
});
121+
});
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1+
const baseConfig = require('./jest.config.base');
2+
13
/** @type {import('@jest/types').Config.InitialOptions} */
24
module.exports = {
3-
preset: 'ts-jest',
4-
rootDir: '..',
5-
testMatch: [
6-
'<rootDir>/e2e/**/*.test.ts',
7-
'<rootDir>/e2e/**/*.test.android.ts',
8-
],
9-
testTimeout: 120000,
10-
maxWorkers: 1,
11-
globalSetup: 'detox/runners/jest/globalSetup',
12-
globalTeardown: 'detox/runners/jest/globalTeardown',
13-
reporters: ['detox/runners/jest/reporter'],
14-
testEnvironment: 'detox/runners/jest/testEnvironment',
15-
verbose: true,
5+
...baseConfig,
6+
testMatch: [...baseConfig.testMatch, '<rootDir>/e2e/**/*.test.android.ts'],
167
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const baseConfig = require('./jest.config.base');
2+
3+
/** @type {import('@jest/types').Config.InitialOptions} */
4+
module.exports = {
5+
...baseConfig,
6+
testMatch: [
7+
...baseConfig.testMatch,
8+
'<rootDir>/e2e/**/*.test.ios.ts',
9+
'<rootDir>/e2e/**/*.test.ios.auto.ts',
10+
],
11+
};

samples/react-native/e2e/jest.config.ios.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const baseConfig = require('./jest.config.base');
2+
3+
/** @type {import('@jest/types').Config.InitialOptions} */
4+
module.exports = {
5+
...baseConfig,
6+
testMatch: [
7+
...baseConfig.testMatch,
8+
'<rootDir>/e2e/**/*.test.ios.ts',
9+
'<rootDir>/e2e/**/*.test.ios.manual.ts',
10+
],
11+
};

samples/react-native/ios/sentryreactnativesample.xcodeproj/xcshareddata/xcschemes/sentryreactnativesample.xcscheme

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
argument = "--sentry-disable-native-start"
6666
isEnabled = "NO">
6767
</CommandLineArgument>
68+
<CommandLineArgument
69+
argument = "--sentry-crash-on-start"
70+
isEnabled = "NO">
71+
</CommandLineArgument>
6872
</CommandLineArguments>
6973
</LaunchAction>
7074
<ProfileAction

samples/react-native/ios/sentryreactnativesample/AppDelegate.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ - (BOOL)application:(UIApplication *)application
2828
[RNSentrySDK start];
2929
}
3030

31+
if ([self shoudCrashOnStart]) {
32+
@throw [NSException exceptionWithName:@"CrashOnStart"
33+
reason:@"This was intentional test crash before JS started."
34+
userInfo:nil];
35+
}
36+
3137
self.moduleName = @"sentry-react-native-sample";
3238

3339
self.dependencyProvider = [RCTAppDependencyProvider new];
@@ -83,4 +89,10 @@ - (BOOL)shouldStartSentry
8389
return ![arguments containsObject:@"--sentry-disable-native-start"];
8490
}
8591

92+
- (BOOL)shoudCrashOnStart
93+
{
94+
NSArray<NSString *> *arguments = [[NSProcessInfo processInfo] arguments];
95+
return [arguments containsObject:@"--sentry-crash-on-start"];
96+
}
97+
8698
@end

samples/react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"set-test-dsn-android": "scripts/set-dsn-aos.mjs",
1616
"set-test-dsn-ios": "scripts/set-dsn-ios.mjs",
1717
"test-android": "scripts/test-android.sh",
18-
"test-ios": "scripts/test-ios.sh",
18+
"test-ios-manual": "scripts/test-ios-manual.sh",
1919
"test-ios-auto": "scripts/test-ios-auto.sh",
2020
"lint": "npx eslint . --ext .js,.jsx,.ts,.tsx",
2121
"fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",

samples/react-native/scripts/test-ios.sh renamed to samples/react-native/scripts/test-ios-manual.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ cd "${thisFilePath}/.."
99

1010
"${thisFilePath}/detect-ios-sim.sh"
1111

12-
detox test --configuration ci.sim
12+
detox test --configuration ci.sim.manual

0 commit comments

Comments
 (0)