Przeglądaj źródła

testing e2e works

Daniel Zlotin 7 lat temu
rodzic
commit
1d5617ebf6

+ 5
- 3
package.json Wyświetl plik

@@ -30,10 +30,12 @@
30 30
     "install-android": "cd playground/android && ./gradlew installDebug",
31 31
     "uninstall-android": "cd playground/android && ./gradlew uninstallAll",
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
-    "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 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 39
     "test-watch": "BABEL_ENV=test jest --coverage --watch",
38 40
     "release": "node ./scripts/release.js"
39 41
   },

scripts/test.android.js → scripts/test.e2e.android.js Wyświetl plik

@@ -1,10 +1,6 @@
1 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 4
   if (process.env.CI) {
9 5
     console.log(`e2e disabled on CI`); //eslint-disable-line
10 6
     return;
@@ -20,12 +16,4 @@ function e2e() {
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 19
 run();

playground/scripts/e2e.ios.js → scripts/test.e2e.ios.js Wyświetl plik

@@ -8,7 +8,7 @@ function buildProjForDetox() {
8 8
 
9 9
   shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
10 10
   const cmd = `RCT_NO_LAUNCH_PACKAGER=true
11
-          cd ios && xcodebuild
11
+          cd ./playground/ios && xcodebuild
12 12
             -scheme ${scheme}
13 13
             ${release ? 'clean build' : 'build'}
14 14
             -project playground.xcodeproj
@@ -34,7 +34,7 @@ function e2e() { //eslint-disable-line
34 34
   try {
35 35
     shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
36 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 39
     shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
40 40
                               BABEL_ENV=test

+ 10
- 0
scripts/test.unit.android.js Wyświetl plik

@@ -0,0 +1,10 @@
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 Wyświetl plik

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