-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
19.crash-handling.test.js
36 lines (30 loc) · 1.33 KB
/
19.crash-handling.test.js
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
const { expectToThrow } = require('./utils/custom-expects');
describe('Crash Handling', () => {
afterAll(async () => {
await device.launchApp({
newInstance: true,
launchArgs: undefined,
});
});
it('Should throw error upon internal app crash', async () => {
await device.reloadReactNative();
await expectToThrow(() => element(by.text('Crash')).tap(), 'The app has crashed');
await expectToThrow(() => element(by.text('Crash')).tap(), 'Failed to reach the app');
});
it('Should recover from app crash', async () => {
await device.launchApp({newInstance: false});
await expect(element(by.text('Sanity'))).toBeVisible();
});
it(':android: should throw error upon invoke crash', async () => {
await device.reloadReactNative();
await expectToThrow(() => element(by.text('UI Crash')).tap(), 'Test Failed: Simulated crash (native)');
});
it(':android: Should throw error upon app bootstrap crash', async () => {
await expectToThrow(() => device.launchApp({
newInstance: true,
launchArgs: { detoxAndroidCrashingActivity: true }
}), 'Failed to run application on the device');
// This is not effectively needed, as if crash handling doesn't go right launchApp would typically
// just hang forever (and thus a timeout will fail the test - not this assertion).
}, 60000);
});