xref: /expo/apps/test-suite/TestUtils.js (revision 8ef929c3)
1'use strict';
2
3import { NativeModules } from 'react-native';
4
5let { ExponentTest } = NativeModules;
6
7export async function acceptPermissionsAndRunCommandAsync(fn) {
8  if (!ExponentTest) {
9    return await fn();
10  }
11
12  let results = await Promise.all([
13    ExponentTest.action({
14      selectorType: 'text',
15      selectorValue: 'Allow',
16      actionType: 'click',
17      delay: 1000,
18      timeout: 100,
19    }),
20    fn(),
21  ]);
22
23  return results[1];
24}
25
26export async function shouldSkipTestsRequiringPermissionsAsync() {
27  if (!ExponentTest || !ExponentTest.shouldSkipTestsRequiringPermissionsAsync) {
28    return false;
29  }
30  return ExponentTest.shouldSkipTestsRequiringPermissionsAsync();
31}
32