forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-unit.js
56 lines (49 loc) · 1.64 KB
/
test-unit.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
53
54
55
56
const includes = require('lodash/includes');
const exec = require('shell-utils').exec;
const android = includes(process.argv, '--android');
const release = includes(process.argv, '--release');
function run() {
if (android) {
runAndroidUnitTests();
} else {
runIosUnitTests();
}
}
function runAndroidUnitTests() {
const conf = release ? 'testReactNative71ReleaseUnitTest' : 'testReactNative71DebugUnitTest';
if (android && process.env.JENKINS_CI) {
const sdkmanager = '/usr/local/share/android-sdk/tools/bin/sdkmanager';
exec.execSync(`yes | ${sdkmanager} --licenses`);
// exec.execSync(`echo y | ${sdkmanager} --update && echo y | ${sdkmanager} --licenses`);
}
exec.execSync(`cd playground/android && ./gradlew ${conf}`);
}
function runIosUnitTests() {
exec.execSync('npm run build');
exec.execSync('npm run pod-install');
testTarget('playground', 'iPhone 13', '15.5');
}
function testTarget(scheme, device, OS = 'latest') {
const conf = release ? `Release` : `Debug`;
exec.execSync(`cd ./playground/ios &&
RCT_NO_LAUNCH_PACKAGER=true
xcodebuild build build-for-testing
-scheme "${scheme}"
-workspace playground.xcworkspace
-sdk iphonesimulator
-configuration ${conf}
-derivedDataPath ./DerivedData/playground
-UseModernBuildSystem=YES
ONLY_ACTIVE_ARCH=YES`);
exec.execSync(`cd ./playground/ios &&
RCT_NO_LAUNCH_PACKAGER=true
xcodebuild test-without-building
-scheme "${scheme}"
-workspace playground.xcworkspace
-sdk iphonesimulator
-configuration ${conf}
-destination 'platform=iOS Simulator,name=${device},OS=${OS}'
-derivedDataPath ./DerivedData/playground
ONLY_ACTIVE_ARCH=YES`);
}
run();