Skip to content

Commit

Permalink
add detox (#155)
Browse files Browse the repository at this point in the history
* add detox

try android

again

use circus, not headless

use hermes with e2e

test hermes is used

verbose

add missing await

use android 28

* use latest deps

* use latest orb

* test fix to orb

* use plain yarn

* remove skin

* use latest orb

* upgrade deps
  • Loading branch information
vonovak authored May 21, 2020
1 parent a5c5ede commit 4580d06
Show file tree
Hide file tree
Showing 18 changed files with 1,727 additions and 1,199 deletions.
102 changes: 74 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,102 @@
version: 2.1

orbs:
rn: react-native-community/[email protected]
rn: react-native-community/[email protected]

# - rn/yarn_install
# fails with Error untarring cache: Error extracting tarball /var/folders/bq/mjrgbpkx5h1g_b22fpv0tlzc0000gn/T/cache376822577 : tmp/yarn/: Cannot extract through symlink tmp/yarn tmp/yarn/v6/: Cannot extract through symlink tmp/yarn/v6 tmp/yarn/v6/.tmp/: Cannot extract through symlink tmp/yarn/v6/.tmp tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/@babel/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/@babel tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/@babel/code-frame/: Cannot extract: exit status 1
# that is why we use yarn install --frozen-lockfile but that is SLOW! help us to fix this!

jobs:
checkout_code:
executor: rn/linux_js
executor:
name: rn/linux_js
node_version: '12.10.0'
steps:
- checkout
- persist_to_workspace:
root: .
paths: .

analyse:
root: .
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
# - rn/yarn_install
# fails with Error untarring cache: Error extracting tarball /var/folders/bq/mjrgbpkx5h1g_b22fpv0tlzc0000gn/T/cache376822577 : tmp/yarn/: Cannot extract through symlink tmp/yarn tmp/yarn/v6/: Cannot extract through symlink tmp/yarn/v6 tmp/yarn/v6/.tmp/: Cannot extract through symlink tmp/yarn/v6/.tmp tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/@babel/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/@babel tmp/yarn/v6/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e-integrity/node_modules/@babel/code-frame/: Cannot extract: exit status 1
- run:
name: Install
command: yarn install --frozen-lockfile
name: yarn install
- run:
name: Lint JS Code (ESLint)
command: yarn run lint
command: yarn lint
name: Run ESLint
- run:
command: yarn flow
name: Flow
command: yarn run flow
- run:
command: yarn test
name: Jest
command: yarn run test
e2e_release_ios:
executor:
name: rn/macos
xcode_version: '11.4.0'
steps:
- attach_workspace:
at: .
- rn/setup_macos_executor:
node_version: '12.10.0'
- rn/ios_simulator_start:
device: 'iPhone 11'
# - rn/yarn_install
- run:
command: yarn install --frozen-lockfile
name: yarn install
- rn/pod_install:
pod_install_directory: 'example/ios'
- run:
command: yarn detox:ios:build:release
name: build for detox
- run:
command: yarn detox:ios:test:release
name: test detox
- store_artifacts:
path: ./artifacts
e2e_release_android:
# we need to use mac to run emulator with acceleration
# see https://support.circleci.com/hc/en-us/articles/360000028928-Testing-with-Android-emulator-on-CircleCI-2-0
executor:
name: rn/macos
xcode_version: '11.4.0'
steps:
- attach_workspace:
at: .
- rn/setup_macos_executor:
node_version: '12.10.0'
# - rn/yarn_install
- run:
command: yarn install --frozen-lockfile
name: yarn install
- rn/android_emulator_start:
logcat_grep: 'com.reactcommunity.rndatetimepicker'
- run:
command: yarn detox:android:build:release
name: build for detox
- run:
command: yarn detox:android:test:release
name: test detox
- store_artifacts:
path: ./artifacts

workflows:
test:
jobs:
- checkout_code
- analyse:
- analyse_js:
requires:
- checkout_code
# - rn/android_build:
# name: build_android_release
# project_path: "example/android"
# requires:
# - analyse
# - rn/android_test:
# detox_configuration: "android.emu.release"
# requires:
# - build_android_release
# - rn/ios_build_and_test:
# project_path: "example/ios/example.xcodeproj"
# device: "iPhone X"
# build_configuration: "Release"
# scheme: "example"
# detox_configuration: "ios.sim.release"
# requires:
# - analyse
- e2e_release_ios:
requires:
- analyse_js
- e2e_release_android:
requires:
- analyse_js
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = {
beforeEach: true,
afterAll: true,
jest: true,
jasmine: true
jasmine: true,
waitFor: true,
detoxCircus: true
}
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ local.properties
# BUCK
buck-out/
\.buckd/
*.keystore

# Editor config
.vscode
Expand Down
1 change: 0 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ yarn-error.log
# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
Expand Down
8 changes: 4 additions & 4 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {Picker} from 'react-native-windows';
import moment from 'moment';
import {DAY_OF_WEEK} from '../src/constants';

const App = () => {
export const App = () => {
const [date, setDate] = useState(new Date(1598051730000));
const [mode, setMode] = useState('date');
const [show, setShow] = useState(false);
Expand Down Expand Up @@ -79,7 +79,9 @@ const App = () => {
<Header />
{global.HermesInternal !== null && (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
<Text testID="hermesIndicator" style={styles.footer}>
Engine: Hermes
</Text>
</View>
)}
<View style={styles.body}>
Expand Down Expand Up @@ -325,5 +327,3 @@ const styles = StyleSheet.create({
width: 350,
},
});

export default App;
28 changes: 16 additions & 12 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ import com.android.build.OutputFile
*/

project.ext.react = [
entryFile: "index.js",
bundleCommand: "ram-bundle",
bundleInDebug: false,
enableHermes: false, // clean and rebuild if changing
root: "../../../",
entryFile: "example/index.js",
enableHermes: true, // clean and rebuild if changing,
// see https://github.com/facebook/react-native/blob/0.62-stable/react.gradle
hermesCommand: "../../../node_modules/hermes-engine/%OS-BIN%/hermes"
]

apply from: "../../../node_modules/react-native/react.gradle"
Expand Down Expand Up @@ -132,6 +133,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
splits {
abi {
Expand Down Expand Up @@ -161,7 +164,6 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

packagingOptions {
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
Expand All @@ -176,22 +178,24 @@ dependencies {

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:"com.facebook.fbjni"
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:"com.facebook.flipper"
exclude group:'com.facebook.flipper'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:"com.facebook.flipper"
exclude group:'com.facebook.flipper'
}

if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
def hermesPath = "../../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
implementation jscFlavor
}

androidTestImplementation('com.wix:detox:+')
}

// Run this once to be able to run the application with BUCK
Expand Down
7 changes: 5 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
package="com.example">

<uses-permission android:name="android.permission.INTERNET" />
<!-- https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#problem-the-app-loads-but-tests-fail-to-start-in-sdk-28 -->

<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.example;

import android.app.Application;
import android.util.Log;
import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {
Expand Down
17 changes: 11 additions & 6 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

buildscript {
ext {
kotlinVersion = "1.3.0"
buildToolsVersion = "28.0.3"
kotlinVersion = "1.3.71"
buildToolsVersion = "29.0.3"
minSdkVersion = 18
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:3.5.2')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -37,6 +37,7 @@ allprojects {

repositories {
mavenLocal()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../node_modules/react-native/android")
Expand All @@ -45,7 +46,11 @@ allprojects {
// Android JSC is installed from npm
url("$rootDir/../../node_modules/jsc-android/dist")
}
google()
maven {
// All of Detox' artifacts are provided via the npm module
url "$rootDir/../../node_modules/detox/Detox-android"
}
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
9 changes: 5 additions & 4 deletions example/e2e/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"setupFilesAfterEnv": ["./init.js"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
"setupFilesAfterEnv": ["./init.js"],
"testEnvironment": "detox/runners/jest/JestCircusEnvironment",
"testRunner": "jest-circus/runner",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
Loading

0 comments on commit 4580d06

Please sign in to comment.