Browse Source

xcode unit tests

Daniel Zlotin 7 years ago
parent
commit
3d3d82dbf2
3 changed files with 36 additions and 0 deletions
  1. 1
    0
      playground/package.json
  2. 34
    0
      playground/scripts/xCodeUnit.js
  3. 1
    0
      scripts/test.ios.js

+ 1
- 0
playground/package.json View File

@@ -7,6 +7,7 @@
7 7
     "start": "adb reverse tcp:8081 tcp:8081; watchman watch-del-all; react-native start",
8 8
     "xcode": "open ios/playground.xcodeproj",
9 9
     "android": "cd android && ./gradlew installDebug",
10
+    "xcodeunit": "node ./scripts/xCodeUnit.js",
10 11
     "e2e": "node ./scripts/e2e.ios.js"
11 12
   },
12 13
   "//": "use react-native-navigation: 2.x.x --> we are manually installing it from a script for quicker workflow. Along with detox and shell-utils",

+ 34
- 0
playground/scripts/xCodeUnit.js View File

@@ -0,0 +1,34 @@
1
+const _ = require('lodash');
2
+const shellUtils = require('shell-utils');
3
+const fs = require('fs');
4
+
5
+function testProject() {
6
+  shellUtils.exec.execSync(`echo 'travis_fold:start:xcodeunit'`);
7
+  const cmd = `RCT_NO_LAUNCH_PACKAGER=true
8
+          cd ios && xcodebuild
9
+            test
10
+            -scheme "playground"
11
+            -project playground.xcodeproj
12
+            -destination 'platform=iOS Simulator,name=iPhone 7'
13
+            `;
14
+
15
+  if (hasXcpretty()) {
16
+    shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
17
+  } else {
18
+    shellUtils.exec.execSync(`${cmd}`);
19
+  }
20
+  shellUtils.exec.execSync(`echo 'travis_fold:end:xcodeunit'`);
21
+}
22
+function hasXcpretty() {
23
+  try {
24
+    return shellUtils.exec.execSyncRead(`which xcpretty`);
25
+  } catch (e) {
26
+    return false;
27
+  }
28
+}
29
+
30
+function run() {
31
+  testProject();
32
+}
33
+
34
+run();

+ 1
- 0
scripts/test.ios.js View File

@@ -3,6 +3,7 @@ const exec = require('shell-utils').exec;
3 3
 function run() {
4 4
   process.chdir('./playground');
5 5
   exec.execSync(`yarn run quickinstall`);
6
+  exec.execSync(`yarn run xcodeunit`);
6 7
   exec.execSync(`yarn run e2e release`);
7 8
   process.chdir('../');
8 9
 }