Browse Source

testing e2e works

Daniel Zlotin 7 years ago
parent
commit
1d5617ebf6
5 changed files with 19 additions and 23 deletions
  1. 5
    3
      package.json
  2. 1
    13
      scripts/test.e2e.android.js
  3. 2
    2
      scripts/test.e2e.ios.js
  4. 10
    0
      scripts/test.unit.android.js
  5. 1
    5
      scripts/test.unit.ios.js

+ 5
- 3
package.json View File

30
     "install-android": "cd playground/android && ./gradlew installDebug",
30
     "install-android": "cd playground/android && ./gradlew installDebug",
31
     "uninstall-android": "cd playground/android && ./gradlew uninstallAll",
31
     "uninstall-android": "cd playground/android && ./gradlew uninstallAll",
32
     "start": "adb reverse tcp:8081 tcp:8081; watchman watch-del-all; node ./node_modules/react-native/local-cli/cli.js start --root=./playground",
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
-    "test-js": "eslint lib/src integration scripts playground/src playground/e2e playground/scripts && BABEL_ENV=test jest --coverage",
34
-    "test-android": "node ./scripts/test.android.js",
33
+    "test-js": "eslint lib/src integration e2e scripts playground/src && BABEL_ENV=test jest --coverage",
34
+    "test-unit-android": "node ./scripts/test.unit.android.js",
35
     "test-unit-ios": "node ./scripts/test.unit.ios.js",
35
     "test-unit-ios": "node ./scripts/test.unit.ios.js",
36
-    "test": "yarn run test-js && yarn run test-android && yarn run test-ios",
36
+    "test-e2e-android": "node ./scripts/test.e2e.android.js",
37
+    "test-e2e-ios": "node ./scripts/test.e2e.ios.js",
38
+    "test": "yarn run test-js && yarn run test-unit-android && yarn run test-e2e-android && yarn run test-unit-ios && yarn run test-e2e-ios",
37
     "test-watch": "BABEL_ENV=test jest --coverage --watch",
39
     "test-watch": "BABEL_ENV=test jest --coverage --watch",
38
     "release": "node ./scripts/release.js"
40
     "release": "node ./scripts/release.js"
39
   },
41
   },

scripts/test.android.js → scripts/test.e2e.android.js View File

1
 const exec = require('shell-utils').exec;
1
 const exec = require('shell-utils').exec;
2
 
2
 
3
-function unitTests() {
4
-  exec.execSync(`cd lib/android && ./gradlew clean testDebugUnitTest`);
5
-}
6
-
7
-function e2e() {
3
+function run() {
8
   if (process.env.CI) {
4
   if (process.env.CI) {
9
     console.log(`e2e disabled on CI`); //eslint-disable-line
5
     console.log(`e2e disabled on CI`); //eslint-disable-line
10
     return;
6
     return;
20
   }
16
   }
21
 }
17
 }
22
 
18
 
23
-function run() {
24
-  if (process.env.CI) {
25
-    exec.execSync(`./scripts/installAndroidSDK.sh`);
26
-  }
27
-  unitTests();
28
-  e2e();
29
-}
30
-
31
 run();
19
 run();

playground/scripts/e2e.ios.js → scripts/test.e2e.ios.js View File

8
 
8
 
9
   shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
9
   shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
10
   const cmd = `RCT_NO_LAUNCH_PACKAGER=true
10
   const cmd = `RCT_NO_LAUNCH_PACKAGER=true
11
-          cd ios && xcodebuild
11
+          cd ./playground/ios && xcodebuild
12
             -scheme ${scheme}
12
             -scheme ${scheme}
13
             ${release ? 'clean build' : 'build'}
13
             ${release ? 'clean build' : 'build'}
14
             -project playground.xcodeproj
14
             -project playground.xcodeproj
34
   try {
34
   try {
35
     shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
35
     shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
36
     shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
36
     shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
37
-    const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
37
+    const detoxAppBuildPath = `playground/ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
38
 
38
 
39
     shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
39
     shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
40
                               BABEL_ENV=test
40
                               BABEL_ENV=test

+ 10
- 0
scripts/test.unit.android.js View File

1
+const exec = require('shell-utils').exec;
2
+
3
+function run() {
4
+  if (process.env.CI) {
5
+    exec.execSync(`./scripts/installAndroidSDK.sh`);
6
+  }
7
+  exec.execSync(`cd lib/android && ./gradlew clean testDebugUnitTest`);
8
+}
9
+
10
+run();

+ 1
- 5
scripts/test.unit.ios.js View File

16
   }
16
   }
17
 }
17
 }
18
 
18
 
19
-function testProject() {
19
+function run() {
20
   try {
20
   try {
21
     shellUtils.exec.execSync(`echo 'travis_fold:start:xcodeunit'`);
21
     shellUtils.exec.execSync(`echo 'travis_fold:start:xcodeunit'`);
22
     runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
22
     runWithXcprettyIfPossible(`RCT_NO_LAUNCH_PACKAGER=true
37
   }
37
   }
38
 }
38
 }
39
 
39
 
40
-function run() {
41
-  testProject();
42
-}
43
-
44
 run();
40
 run();