Browse Source

unit testing ios works

Daniel Zlotin 7 years ago
parent
commit
a4ec6c5367
3 changed files with 10 additions and 20 deletions
  1. 1
    1
      package.json
  2. 0
    11
      scripts/test.ios.js
  3. 9
    8
      scripts/test.unit.ios.js

+ 1
- 1
package.json View File

@@ -32,7 +32,7 @@
32 32
     "start": "adb reverse tcp:8081 tcp:8081; watchman watch-del-all; node ./node_modules/react-native/local-cli/cli.js start --root=./playground",
33 33
     "test-js": "eslint lib/src integration scripts playground/src playground/e2e playground/scripts && BABEL_ENV=test jest --coverage",
34 34
     "test-android": "node ./scripts/test.android.js",
35
-    "test-ios": "node ./scripts/test.ios.js",
35
+    "test-unit-ios": "node ./scripts/test.unit.ios.js",
36 36
     "test": "yarn run test-js && yarn run test-android && yarn run test-ios",
37 37
     "test-watch": "BABEL_ENV=test jest --coverage --watch",
38 38
     "release": "node ./scripts/release.js"

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

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

scripts/unit.ios.js → scripts/test.unit.ios.js View File

@@ -1,6 +1,4 @@
1
-const _ = require('lodash');
2 1
 const shellUtils = require('shell-utils');
3
-const fs = require('fs');
4 2
 
5 3
 function runWithXcprettyIfPossible(cmd) {
6 4
   if (hasXcpretty()) {
@@ -19,21 +17,24 @@ function hasXcpretty() {
19 17
 }
20 18
 
21 19
 function testProject() {
22
-  shellUtils.exec.execSync(`echo 'travis_fold:start:xcodeunit'`);
23
-  runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
24
-          cd ios && xcodebuild
20
+  try {
21
+    shellUtils.exec.execSync(`echo 'travis_fold:start:xcodeunit'`);
22
+    runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
23
+          cd ./playground/ios && xcodebuild
25 24
             build build-for-testing
26 25
             -scheme "playground"
27 26
             -project playground.xcodeproj
28 27
             -sdk iphonesimulator
29 28
             -configuration Debug`);
30
-  runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
31
-          cd ios && xcodebuild
29
+    runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
30
+          cd ./playground/ios && xcodebuild
32 31
             test-without-building
33 32
             -scheme "playground"
34 33
             -project playground.xcodeproj
35 34
             -destination 'platform=iOS Simulator,name=iPhone 7'`);
36
-  shellUtils.exec.execSync(`echo 'travis_fold:end:xcodeunit'`);
35
+  } finally {
36
+    shellUtils.exec.execSync(`echo 'travis_fold:end:xcodeunit'`);
37
+  }
37 38
 }
38 39
 
39 40
 function run() {