[tests] simplify testing project guide and move detox-cli global to be a devDep

This commit is contained in:
Salakar
2018-09-09 01:11:31 +01:00
parent 1a481e2edf
commit f839acad1d
3 changed files with 34 additions and 64 deletions

View File

@@ -6,77 +6,64 @@ Our tests are powered by [Jet ✈️](https://github.com/invertase/jet).
## Requirements
- Make sure you have Xcode installed (tested with Xcode 9+).
- Make sure you have Xcode installed (tested with Xcode 9.2+).
- Make sure you have NodeJS installed (Node 8.4.0 and up is required).
- Make sure you have all required global dependencies installed:
- React Native CLI:
```bash
npm install -g react-native-cli
```
- Make sure you have all required dependencies installed:
- [Apple Sim Utils](https://github.com/wix/AppleSimulatorUtils):
```bash
brew tap wix/brew
brew install wix/brew/applesimutils
```
- Detox CLI:
```bash
npm install -g detox-cli
```
---
### Step 1: Install test project dependencies
NPM install at project root and also inside tests directory.
Yarn install at project root and also inside tests directory.
Also install tests project iOS Pods.
```bash
npm i
cd tests/ && npm i
yarn
cd tests/ && yarn
cd tests/ios && pod install --repo-update
```
---
### Step 2: Start Build & Packager Scripts
### Step 2: Start Packager Script
1. First, start the build script to compile the library and watch for changes;
Start the React Native packager using the script provided;
```bash
npm run build-src-watch
```
> This will automatically rebuild on any JS changes to the library code. You don't need to restart this, leave it running whilst developing.
2. Secondly, start the React Native packager using the script provided;
```bash
cd tests/ && npm run packager-jet
cd tests/ && yarn run packager-jet
```
> ⚠️ It must be this script only that starts the RN Packager, using the default RN packager command will not work.
> ⚠️ Also ensure that all existing packagers are terminated and that you have no React Native debugger tabs open on your browsers.
> This packager will automatically rebuild on any JS changes to the library code. You don't need to restart this, leave it running whilst developing.
---
### Step 3: Build Native App
The first build for each platform will take a while. Subsequent builds are much much quicker ⚡️
As always; the first build for each platform will take a while. Subsequent builds are much much quicker ⚡️
> ⚠️ You must rebuild native every time you make changes to native code (anything in /android /ios directories).
#### Android
```bash
cd tests/ && npm run build-android
cd tests/ && yarn run build-android
```
#### iOS
```bash
cd tests/ && npm run build-ios
cd tests/ && yarn run build-ios
```
---
@@ -96,13 +83,13 @@ This action will launch a new simulator (if not already open) and run the tests
#### Android
```bash
cd tests/ && npm run test-android
cd tests/ && yarn run test-android
```
#### iOS
```bash
cd tests/ && npm run test-ios
cd tests/ && yarn run test-ios
```
The `test-${platform}` commands uninstall any existing app and installs a fresh copy. You can
@@ -110,10 +97,10 @@ run `test-${platform}-reuse` instead if you don't need to re-install the app (i.
Just remember to use `test-${platform}` if you made native code changes and rebuilt - after installing once you can
go back to using the `reuse` variant.
The `cover` variant of the npm scripts will additionally run tests with coverage.
The `cover` variant of the yarn scripts will additionally run tests with coverage.
Coverage is output to the root directory of the project: `react-native-firebase/coverage`,
open `react-native-firebase/coverage/lcov-report/index.html` in your browser after running tests
to view coverage output.
to view detailed coverage output.
---
@@ -126,27 +113,3 @@ Another way to do this is via adding a `--grep` option to e2e/mocha.opts file, e
> 💡 Don't forget to remove these before committing your code and submitting a pull request
For more Mocha options see https://mochajs.org/#usage
### TODO - Troubleshooting
These notes are TODO.
Gradle issues... https://stackoverflow.com/questions/46917365/error-could-not-initialize-class-com-android-sdklib-repository-androidsdkhandle?rq=1
mac: `export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"`
windows `"C://Program Files/Java/jdk_1.x_"`
android sdk root `export ANDROID_SDK_ROOT="/Users/mike/Library/Android/sdk"`
Add platform-tools to your path
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
Name: TestingAVD
CPU/ABI: null (null)
Path: /Users/mike/.android/avd/Actually_THIS_one.avd
Error: Failed to parse properties from /Users/mike/.android/avd/Actually_THIS_one.avd/config.ini

View File

@@ -6,9 +6,8 @@
"packager-chrome": "node node_modules/react-native/local-cli/cli.js start --platforms ios,android",
"packager-jet": "REACT_DEBUGGER='echo nope' node node_modules/react-native/local-cli/cli.js start",
"packager-jet-reset-cache": "REACT_DEBUGGER='echo nope' node node_modules/react-native/local-cli/cli.js start --reset-cache",
"build-android": "detox build --configuration android.emu.debug",
"build-ios": "detox build --configuration ios.sim.debug",
"test": "npm run test-android && test-ios",
"build-android": "detox build --configuration android.emu.debug",
"test-android": "detox test --configuration android.emu.debug",
"test-android-reuse": "detox test --configuration android.emu.debug --reuse",
"test-android-cover": "nyc detox test --configuration android.emu.debug",
@@ -34,11 +33,12 @@
"sinon": "^6.2.0"
},
"devDependencies": {
"@babel/runtime": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-eslint": "^9.0.0",
"babel-plugin-istanbul": "^5.0.1",
"babel-plugin-module-resolver": "^3.1.1",
"detox-cli": "^7.4.0",
"eslint": "^5.5.0",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-flowtype": "^2.46.3",
@@ -77,12 +77,6 @@
"specs": "e2e",
"runner-config": "e2e/mocha.opts",
"configurations": {
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/testing.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/testing.xcworkspace -scheme testing -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -quiet",
"type": "ios.simulator",
"name": "iPhone 7 Plus"
},
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/testing.app",
"build": "xcodebuild -workspace ios/testing.xcworkspace -scheme testing -parallelizeTargets -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
@@ -96,6 +90,12 @@
"type": "android.emulator",
"name": "TestingAVD"
},
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/testing.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/testing.xcworkspace -scheme testing -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -quiet",
"type": "ios.simulator",
"name": "iPhone 7 Plus"
},
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
"build": "pushd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && popd",

View File

@@ -2763,6 +2763,13 @@ detect-newline@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2"
detox-cli@^7.4.0:
version "7.4.0"
resolved "https://registry.yarnpkg.com/detox-cli/-/detox-cli-7.4.0.tgz#d1de0d4a4bb2f29ffe5383474fd5d1f50dfa3952"
dependencies:
commander "^2.9.0"
minimist "^1.2.0"
detox@^8.1.1:
version "8.2.3"
resolved "https://registry.yarnpkg.com/detox/-/detox-8.2.3.tgz#574ffbc3680e7285a07a340ede6f415163bbc725"