-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathReactNativeExceptionlessClient.test.ts
More file actions
72 lines (59 loc) · 2.75 KB
/
Copy pathReactNativeExceptionlessClient.test.ts
File metadata and controls
72 lines (59 loc) · 2.75 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
import { afterEach, describe, expect, test } from "vitest";
import { AsyncStorageProvider } from "../src/storage/AsyncStorageProvider.js";
import { ReactNativeExceptionlessClient } from "../src/ReactNativeExceptionlessClient.js";
describe("ReactNativeExceptionlessClient", () => {
afterEach(async () => {
const { Platform } = await import("react-native");
Object.defineProperty(Platform, "OS", { value: "ios", writable: true });
});
test("should configure documented react native plugins and persisted queue storage", async () => {
const client = new ReactNativeExceptionlessClient();
await client.startup((config) => {
config.apiKey = "UNIT_TEST_API_KEY";
config.updateSettingsWhenIdleInterval = -1;
});
try {
const pluginNames = client.config.plugins.map((plugin) => plugin.name);
expect(pluginNames).toContain("NativeCrashPlugin");
expect(pluginNames).toContain("ReactNativeErrorPlugin");
expect(pluginNames).toContain("ReactNativeEnvironmentInfoPlugin");
expect(pluginNames).toContain("ReactNativeGlobalHandlerPlugin");
expect(pluginNames).toContain("ReactNativeLifeCyclePlugin");
expect(pluginNames).not.toContain("SimpleErrorPlugin");
expect(client.config.services.storage).toBeInstanceOf(AsyncStorageProvider);
expect(client.config.usePersistedQueueStorage).toBe(true);
} finally {
await client.suspend();
}
});
test("should support startup with an api key string", async () => {
const client = new ReactNativeExceptionlessClient();
await client.startup("UNIT_TEST_API_KEY");
try {
expect(client.config.apiKey).toBe("UNIT_TEST_API_KEY");
expect(client.config.plugins.map((plugin) => plugin.name)).toContain("ReactNativeGlobalHandlerPlugin");
} finally {
await client.suspend();
}
});
test("should not configure native crash reporting on Android", async () => {
const { Platform } = await import("react-native");
Object.defineProperty(Platform, "OS", { value: "android", writable: true });
const client = new ReactNativeExceptionlessClient();
await client.startup((config) => {
config.apiKey = "UNIT_TEST_API_KEY";
config.updateSettingsWhenIdleInterval = -1;
});
try {
const pluginNames = client.config.plugins.map((plugin) => plugin.name);
expect(pluginNames).not.toContain("NativeCrashPlugin");
expect(pluginNames).toContain("ReactNativeErrorPlugin");
expect(pluginNames).toContain("ReactNativeEnvironmentInfoPlugin");
expect(pluginNames).toContain("ReactNativeGlobalHandlerPlugin");
expect(pluginNames).toContain("ReactNativeLifeCyclePlugin");
expect(pluginNames).not.toContain("SimpleErrorPlugin");
} finally {
await client.suspend();
}
});
});