react-native-firebase/tests
Salakar 9a3cc03c01 [build][ci] use env for service account 2018-09-03 20:38:31 +01:00
..
android add tests android app 2018-08-25 13:38:05 +01:00
e2e add tests project 2018-08-25 13:40:25 +01:00
functions add tests project 2018-08-25 13:40:25 +01:00
helpers [build][ci] use env for service account 2018-09-03 20:38:31 +01:00
ios [tests] update pod lock 2018-08-29 16:23:32 +01:00
.babelrc add tests project 2018-08-25 13:40:25 +01:00
.buckconfig add tests project 2018-08-25 13:40:25 +01:00
.editorconfig add tests project 2018-08-25 13:40:25 +01:00
.eslintrc add tests project 2018-08-25 13:40:25 +01:00
.firebaserc add tests project 2018-08-25 13:40:25 +01:00
.flowconfig add tests project 2018-08-25 13:40:25 +01:00
.gitignore add tests project 2018-08-25 13:40:25 +01:00
.watchmanconfig add tests project 2018-08-25 13:40:25 +01:00
README.md [tests] misc readme 2018-08-25 13:57:57 +01:00
app.js add tests project 2018-08-25 13:40:25 +01:00
firebase.json add tests project 2018-08-25 13:40:25 +01:00
index.android.js add tests project 2018-08-25 13:40:25 +01:00
index.js add tests project 2018-08-25 13:40:25 +01:00
package-lock.json [tests] update to detox v8.2.3 2018-09-02 04:47:53 +01:00
package.json [tests] update to detox v8.2.3 2018-09-02 04:47:53 +01:00
rn-cli.config.js [tests] remove redundant metro blacklist config 2018-08-29 16:24:26 +01:00

README.md

React Native Firebase - Testing Project

Our tests are powered by Jet ✈️.

Note: instructions in this file assume you're running terminal commands from the root of the project and not from inside the tests directory.

Requirements

  • Make sure you have Xcode installed (tested with Xcode 9+).
  • 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:
      npm install -g react-native-cli
      
    • Apple Sim Utils:
      brew tap wix/brew
      brew install wix/brew/applesimutils
      
    • Detox CLI:
      npm install -g detox-cli
      

Step 1: Install test project dependencies

NPM install at project root and also inside tests directory.

Also install tests project iOS Pods.

npm i
cd tests/ && npm i
cd tests/ios && pod install --repo-update

Step 2: Start Build & Packager Scripts

  1. First, start the build script to compile the library and watch for changes;
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.

  1. Secondly, start the React Native packager using the script provided;
cd tests/ && npm 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.


Step 3: Build Native App

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

cd tests/ && npm run build-android

iOS

cd tests/ && npm run build-ios

Step 4: Finally, run the tests

This action will launch a new simulator (if not already open) and run the tests on it.

💡 iOS by default will background launch the simulator - to have it launch in the foreground make sure any simulator is currently open, Finder -> Simulator.app.

💡 Android by default looks for a pre-defined emulator named TestingAVD - make sure you have one named the same setup on Android Studio. Or you can change this name in the package.json of the tests project (don't commit the change though please). DO NOT rename an existing AVD to this name - it will not work, rename does not change the file path currently so Detox will fail to find the AVD in the correct directory. Create a new one with Google Play Services.

Android

cd tests/ && npm run test-android

iOS

cd tests/ && npm run test-ios

The test-${platform} commands uninstall any existing app and installs a fresh copy. You can run test-${platform}-reuse instead if you don't need to re-install the app (i.e only making JS code changes). 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. 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.


Running specific tests

Mocha supports the .only syntax, e.g. instead of describe(...) || it(...) you can use describe.only(...) || it.only(...) to only run that specific context or test.

Another way to do this is via adding a --grep option to e2e/mocha.opts file, e.g. --grep auth for all tests that have auth in the file path or tests descriptions.

💡 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