-
Notifications
You must be signed in to change notification settings - Fork 7
/
TestProperties.js
52 lines (47 loc) · 1.45 KB
/
TestProperties.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Animated } from 'react-native';
import getTransitionConfig from 'react-navigation/src/views/CardStack/TransitionConfigs';
import {
ENVIRONMENT,
IS_AUTOMATION_BUILD,
IS_IOS,
TESTING_ENVIRONMENTS
} from './Constants';
export function testProperties(id) {
if (TESTING_ENVIRONMENTS.includes(ENVIRONMENT)) {
// Detox checks if an element is accessible, so that's why `accessible: true,` needs to be added,
// this will only be done with on the DEV build
const accessible = {
accessible: !IS_AUTOMATION_BUILD
};
if (IS_IOS) {
return { ...accessible, testID: `test-${id}` };
}
return { ...accessible, accessibilityLabel: `test-${id}` };
}
return null;
}
/**
* Setup the app for a specific automation build
*/
export function setupAutomation() {
if (!IS_AUTOMATION_BUILD) {
return;
}
// Disable the yellow box
console.disableYellowBox = true; // eslint-disable-line no-console
disableAnimations();
}
/**
* Disable all animations
*/
function disableAnimations() {
const stubs = require('stubs');
const AnimatedTiming = Animated.timing;
stubs(Animated, 'timing', (...props) => {
props[1].duration = 0; // eslint-disable-line no-param-reassign
props[1].delay = 0; // eslint-disable-line no-param-reassign
return AnimatedTiming(...props);
});
// @todo: Dirty hack for now to stub the card duration, need to find a better way
stubs(getTransitionConfig, 'getTransitionConfig', () => ({}));
}