-
-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathcaptureMessage.test.android.auto.ts
More file actions
99 lines (83 loc) · 2.7 KB
/
captureMessage.test.android.auto.ts
File metadata and controls
99 lines (83 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { describe, it, beforeAll, expect, afterAll } from '@jest/globals';
import { Envelope, EventItem } from '@sentry/core';
import {
createSentryServer,
containingEventWithAndroidMessage,
} from '../../utils/mockedSentryServer';
import { getItemOfTypeFrom } from '../../utils/event';
import { maestro } from '../../utils/maestro';
describe('Capture message (auto init from JS)', () => {
let sentryServer = createSentryServer();
let envelope: Envelope;
beforeAll(async () => {
await sentryServer.start();
const envelopePromise = sentryServer.waitForEnvelope(
containingEventWithAndroidMessage('Captured message'),
);
await maestro('tests/captureMessage/captureMessage.test.yml');
envelope = await envelopePromise;
}, 240000); // 240 seconds timeout
afterAll(async () => {
await sentryServer.close();
});
it('envelope contains message event', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');
expect(item).toEqual([
{
content_type: 'application/json',
length: expect.any(Number),
type: 'event',
},
expect.objectContaining({
level: 'info',
message: {
message: 'Captured message',
},
platform: 'javascript',
}),
]);
});
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),
brand: expect.any(String),
family: expect.any(String),
manufacturer: expect.any(String),
model: expect.any(String),
simulator: expect.any(Boolean),
}),
}),
}),
);
});
it('contains app context', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');
expect(item?.[1]).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
app: expect.objectContaining({
app_identifier: expect.any(String),
app_name: expect.any(String),
app_version: expect.any(String),
}),
}),
}),
);
});
it('SDK initialized from JavaScript (auto init)', async () => {
const item = getItemOfTypeFrom<EventItem>(envelope, 'event');
// Verify that native SDK was NOT initialized before JS
// When auto init, the SDK is initialized from JavaScript
expect(item?.[1]).toEqual(
expect.objectContaining({
sdk: expect.objectContaining({
name: 'sentry.javascript.react-native',
}),
}),
);
});
});