-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestUtils.js
More file actions
119 lines (109 loc) · 3.88 KB
/
TestUtils.js
File metadata and controls
119 lines (109 loc) · 3.88 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict';
import { Platform, NativeModules } from 'react-native';
import { Constants } from 'expo';
const { ExponentTest } = NativeModules;
function browserSupportsWebGL() {
try {
const canvas = document.createElement('canvas');
return (
!!window.WebGLRenderingContext &&
(canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
);
} catch (e) {
return false;
}
}
// List of all modules for tests. Each file path must be statically present for
// the packager to pick them all up.
export function getTestModules() {
if (Platform.OS === 'web') {
const modules = [
require('./tests/Import1'),
require('./tests/Crypto'),
require('./tests/Random'),
];
if (browserSupportsWebGL()) {
modules.push(require('./tests/GLView'));
}
return modules;
}
const modules = [
require('./tests/Basic'),
require('./tests/Import1'),
require('./tests/Import2'),
require('./tests/Import3'),
require('./tests/Asset'),
require('./tests/Constants'),
require('./tests/Crypto'),
require('./tests/FileSystem'),
require('./tests/GLView'),
require('./tests/Haptics'),
require('./tests/Localization'),
require('./tests/Recording'),
require('./tests/ScreenOrientation'),
require('./tests/SecureStore'),
require('./tests/Segment'),
require('./tests/Speech'),
require('./tests/SQLite'),
require('./tests/Random'),
require('./tests/Payments'),
require('./tests/AdMobInterstitial'),
require('./tests/AdMobBanner'),
require('./tests/AdMobPublisherBanner'),
require('./tests/AdMobRewarded'),
require('./tests/FBBannerAd'),
];
if (ExponentTest && !ExponentTest.isInCI) {
// Invalid placementId in CI (all tests fail)
modules.push(require('./tests/FBNativeAd'));
// Requires interaction (sign in popup)
modules.push(require('./tests/GoogleSignIn'));
// Popup to request device's location which uses Google's location service
modules.push(require('./tests/Location'));
// Fails to redirect because of malformed URL in published version with release channel parameter
modules.push(require('./tests/Linking'));
// Requires permission
modules.push(require('./tests/Calendar'));
modules.push(require('./tests/Contacts'));
modules.push(require('./tests/Permissions'));
modules.push(require('./tests/MediaLibrary'));
modules.push(require('./tests/Notifications'));
if (Constants.isDevice) modules.push(require('./tests/Brightness'));
// Crashes app when mounting component
modules.push(require('./tests/Video'));
// "sdkUnversionedTestSuite failed: java.lang.NullPointerException: Attempt to invoke interface method
// 'java.util.Map org.unimodules.interfaces.taskManager.TaskInterface.getOptions()' on a null object reference"
modules.push(require('./tests/TaskManager'));
// Audio tests are flaky in CI due to asynchronous fetching of resources
modules.push(require('./tests/Audio'));
// The Camera tests are flaky on iOS, i.e. they fail randomly
if (Constants.isDevice && Platform.OS === 'android') modules.push(require('./tests/Camera'));
}
if (Platform.OS === 'android') modules.push(require('./tests/JSC'));
if (Constants.isDevice) {
modules.push(require('./tests/BarCodeScanner'));
}
return modules;
}
export async function acceptPermissionsAndRunCommandAsync(fn) {
if (!ExponentTest) {
return await fn();
}
const results = await Promise.all([
ExponentTest.action({
selectorType: 'text',
selectorValue: 'Allow',
actionType: 'click',
delay: 1000,
timeout: 100,
}),
fn(),
]);
return results[1];
}
export async function shouldSkipTestsRequiringPermissionsAsync() {
if (!ExponentTest || !ExponentTest.shouldSkipTestsRequiringPermissionsAsync) {
return false;
}
return ExponentTest.shouldSkipTestsRequiringPermissionsAsync();
}