Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cc9543f
chore(samples): Add package scripts for native builds, dsn and testing
krystofwoldrich Feb 18, 2025
c20ac08
Merge branch 'capture-app-start-errors' into kw-simplify-local-sample…
krystofwoldrich Feb 18, 2025
f2a14c9
fix ci
krystofwoldrich Feb 19, 2025
d9fec19
fix android archive path
krystofwoldrich Feb 19, 2025
6b8f314
fix ios build release
krystofwoldrich Feb 19, 2025
25ab23b
fix(sample-e2e): Fix type errors missing sentry/core and afterAll
krystofwoldrich Feb 19, 2025
20a132e
Merge branch 'kw-fix-bad-merge' into kw-simplify-local-sample-testing
krystofwoldrich Feb 19, 2025
8b2227a
fix IOS_DEVICE empty check
krystofwoldrich Feb 20, 2025
d5e8e92
Merge branch 'capture-app-start-errors' into kw-simplify-local-sample…
krystofwoldrich Feb 20, 2025
20e7f55
fix ios archive
krystofwoldrich Feb 20, 2025
56fe4b8
test(e2e): Verify captured Errors Screen transaction
krystofwoldrich Feb 20, 2025
4cfc937
add more tests
krystofwoldrich Feb 21, 2025
b484b07
Merge branch 'capture-app-start-errors' into kw-test-transactions
krystofwoldrich Feb 24, 2025
86a675e
revert dsn change
krystofwoldrich Feb 24, 2025
71fada9
fix lint
krystofwoldrich Feb 24, 2025
0d6f543
remove jest extended from sample e2e tests
krystofwoldrich Feb 24, 2025
c5c93d2
Relax test to expect any type of app start, remove native frames as m…
krystofwoldrich Feb 24, 2025
def6e30
add app, device and react native context smoke tests
krystofwoldrich Feb 24, 2025
3aae5bf
include transaction name in the tests
krystofwoldrich Feb 24, 2025
97e1b30
remove jest extended
krystofwoldrich Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 102 additions & 5 deletions samples/react-native/e2e/captureMessage.test.android.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { describe, it, beforeAll, expect, afterAll } from '@jest/globals';
import { Envelope } from '@sentry/core';
import { Envelope, EventItem } from '@sentry/core';
import { device } from 'detox';
import {
createSentryServer,
containingEvent,
} from './utils/mockedSentryServer';
import { HEADER, ITEMS } from './utils/consts';
import { tap } from './utils/tap';
import { getItemOfTypeFrom } from './utils/event';

describe('Capture message', () => {
let sentryServer = createSentryServer();
Expand All @@ -27,9 +27,7 @@ describe('Capture message', () => {
});

it('envelope contains message event', async () => {
const item = (envelope[ITEMS] as [{ type?: string }, unknown][]).find(
i => i[HEADER].type === 'event',
);
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item).toEqual([
{
Expand All @@ -46,4 +44,103 @@ describe('Capture message', () => {
}),
]);
});

it('contains device context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
device: expect.objectContaining({
battery_level: expect.any(Number),
battery_temperature: expect.any(Number),
boot_time: expect.any(String),
brand: expect.any(String),
charging: expect.any(Boolean),
connection_type: expect.any(String),
family: expect.any(String),
free_memory: expect.any(Number),
free_storage: expect.any(Number),
id: expect.any(String),
language: expect.any(String),
locale: expect.any(String),
low_memory: expect.any(Boolean),
manufacturer: expect.any(String),
memory_size: expect.any(Number),
model: expect.any(String),
model_id: expect.any(String),
online: expect.any(Boolean),
orientation: expect.any(String),
processor_count: expect.any(Number),
processor_frequency: expect.any(Number),
screen_density: expect.any(Number),
screen_dpi: expect.any(Number),
screen_height_pixels: expect.any(Number),
screen_width_pixels: expect.any(Number),
simulator: expect.any(Boolean),
storage_size: expect.any(Number),
timezone: expect.any(String),
}),
}),
}),
);
});

it('contains app context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
app: expect.objectContaining({
app_build: expect.any(String),
app_identifier: expect.any(String),
app_name: expect.any(String),
app_start_time: expect.any(String),
app_version: expect.any(String),
in_foreground: expect.any(Boolean),
view_names: ['ErrorsScreen'],
}),
}),
}),
);
});

it('contains os context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
os: {
build: expect.any(String),
kernel_version: expect.any(String),
name: 'Android',
rooted: expect.any(Boolean),
version: expect.any(String),
},
}),
}),
);
});

it('contains react native context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
react_native_context: {
expo: false,
fabric: expect.any(Boolean),
hermes_debug_info: expect.any(Boolean),
hermes_version: expect.any(String),
js_engine: 'hermes',
react_native_version: expect.any(String),
turbo_module: expect.any(Boolean),
},
}),
}),
);
});
});
90 changes: 85 additions & 5 deletions samples/react-native/e2e/captureMessage.test.ios.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { describe, it, beforeAll, expect, afterAll } from '@jest/globals';
import { Envelope } from '@sentry/core';
import { Envelope, EventItem } from '@sentry/core';
import { device } from 'detox';
import {
createSentryServer,
containingEvent,
} from './utils/mockedSentryServer';
import { HEADER, ITEMS } from './utils/consts';
import { tap } from './utils/tap';
import { getItemOfTypeFrom } from './utils/event';

describe('Capture message', () => {
let sentryServer = createSentryServer();
Expand All @@ -27,9 +27,7 @@ describe('Capture message', () => {
});

it('envelope contains message event', async () => {
const item = (envelope[ITEMS] as [{ type?: string }, unknown][]).find(
i => i[HEADER].type === 'event',
);
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item).toEqual([
{
Expand All @@ -43,4 +41,86 @@ describe('Capture message', () => {
}),
]);
});

it('contains device context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
device: expect.objectContaining({
arch: expect.any(String),
family: expect.any(String),
free_memory: expect.any(Number),
locale: expect.any(String),
memory_size: expect.any(Number),
model: expect.any(String),
model_id: expect.any(String),
processor_count: expect.any(Number),
simulator: expect.any(Boolean),
thermal_state: expect.any(String),
usable_memory: expect.any(Number),
}),
}),
}),
);
});

it('contains app context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
app: expect.objectContaining({
app_build: expect.any(String),
app_identifier: expect.any(String),
app_name: expect.any(String),
app_start_time: expect.any(String),
app_version: expect.any(String),
in_foreground: expect.any(Boolean),
// view_names: ['ErrorsScreen-jn5qquvH9Nz'], // TODO: fix this generated hash should not be part of the name
}),
}),
}),
);
});

it('contains os context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
os: {
build: expect.any(String),
kernel_version: expect.any(String),
name: 'iOS',
rooted: expect.any(Boolean),
version: expect.any(String),
},
}),
}),
);
});

it('contains react native context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');

expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
react_native_context: {
expo: false,
fabric: expect.any(Boolean),
hermes_debug_info: expect.any(Boolean),
hermes_version: expect.any(String),
js_engine: 'hermes',
react_native_version: expect.any(String),
turbo_module: expect.any(Boolean),
},
}),
}),
);
});
});
Loading
Loading