Skip to content

Commit

Permalink
chore: setup detox for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jan 7, 2020
1 parent 5614a7c commit fbadea4
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 39 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

name: Detox (iOS)

on: [push]

jobs:
build:
runs-on: macOS-latest
timeout-minutes: 15

env:
DEVELOPER_DIR: /Applications/Xcode_11.2.app
steps:
- uses: actions/checkout@v1

- name: Use Node.js 10
uses: actions/setup-node@v1
with:
node-version: 12

- name: Get Yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache Yarn packages
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile

- name: Cache Pods
uses: actions/cache@v1
with:
path: example/ios/Pods
key: pods-${{ hashFiles('**/Podfile.lock') }}

- name: Update Pods
run: |
gem update cocoapods xcodeproj
cd example/ios
pod install
- name: Configure dependencies
run: |
brew tap wix/brew
brew install applesimutils
yarn global add detox-cli
- name: Cache Detox build
uses: actions/cache@v1
id: detox-cache
with:
path: example/ios/build
key: detox-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/Podfile.lock') }}

- name: Build Detox
if: steps.detox-cache.outputs.cache-hit != 'true'
run: |
cd example
detox build --configuration ios.sim.release
- name: Run Detox tests
run: |
cd example
detox test --configuration ios.sim.release --cleanup --debug-synchronization 200
9 changes: 9 additions & 0 deletions example/e2e/__integration_tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { by, element, expect, device } from 'detox';

beforeEach(async () => {
await device.reloadReactNative();
});

it('has dark theme toggle', async () => {
await expect(element(by.text('Dark theme'))).toBeVisible();
});
6 changes: 6 additions & 0 deletions example/e2e/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"setupFilesAfterEnv": ["./init.js"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
29 changes: 29 additions & 0 deletions example/e2e/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable import/no-commonjs, jest/no-jasmine-globals */
/* eslint-env jest, jasmine */

const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');

// Set the default timeout
jest.setTimeout(120000);

jasmine.getEnv().addReporter(adapter);

// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => {
await detox.init(config);
}, 300000);

beforeEach(async () => {
await adapter.beforeEach();
});

afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});
68 changes: 34 additions & 34 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ PODS:
- React
- RNReanimated (1.4.0):
- React
- RNScreens (2.0.0-alpha.17):
- RNScreens (2.0.0-alpha.19):
- React
- UMBarCodeScannerInterface (5.0.0)
- UMCameraInterface (5.0.0)
Expand All @@ -274,15 +274,15 @@ PODS:

DEPENDENCIES:
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- EXAppLoaderProvider (from `../node_modules/expo/node_modules/expo-app-loader-provider/ios`)
- EXConstants (from `../node_modules/expo/node_modules/expo-constants/ios`)
- EXAppLoaderProvider (from `../node_modules/expo-app-loader-provider/ios`)
- EXConstants (from `../node_modules/expo-constants/ios`)
- EXErrorRecovery (from `../node_modules/expo-error-recovery/ios`)
- EXFileSystem (from `../node_modules/expo/node_modules/expo-file-system/ios`)
- EXFileSystem (from `../node_modules/expo-file-system/ios`)
- EXFont (from `../node_modules/expo-font/ios`)
- EXKeepAwake (from `../node_modules/expo-keep-awake/ios`)
- EXLinearGradient (from `../node_modules/expo-linear-gradient/ios`)
- EXLocation (from `../node_modules/expo-location/ios`)
- EXPermissions (from `../node_modules/expo/node_modules/expo-permissions/ios`)
- EXPermissions (from `../node_modules/expo-permissions/ios`)
- EXSQLite (from `../node_modules/expo-sqlite/ios`)
- EXWebBrowser (from `../node_modules/expo-web-browser/ios`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
Expand Down Expand Up @@ -316,18 +316,18 @@ DEPENDENCIES:
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
- UMBarCodeScannerInterface (from `../node_modules/expo/node_modules/unimodules-barcode-scanner-interface/ios`)
- UMCameraInterface (from `../node_modules/expo/node_modules/unimodules-camera-interface/ios`)
- UMConstantsInterface (from `../node_modules/expo/node_modules/unimodules-constants-interface/ios`)
- "UMCore (from `../node_modules/expo/node_modules/@unimodules/core/ios`)"
- UMFaceDetectorInterface (from `../node_modules/expo/node_modules/unimodules-face-detector-interface/ios`)
- UMFileSystemInterface (from `../node_modules/expo/node_modules/unimodules-file-system-interface/ios`)
- UMFontInterface (from `../node_modules/expo/node_modules/unimodules-font-interface/ios`)
- UMImageLoaderInterface (from `../node_modules/expo/node_modules/unimodules-image-loader-interface/ios`)
- UMPermissionsInterface (from `../node_modules/expo/node_modules/unimodules-permissions-interface/ios`)
- "UMReactNativeAdapter (from `../node_modules/expo/node_modules/@unimodules/react-native-adapter/ios`)"
- UMSensorsInterface (from `../node_modules/expo/node_modules/unimodules-sensors-interface/ios`)
- UMTaskManagerInterface (from `../node_modules/expo/node_modules/unimodules-task-manager-interface/ios`)
- UMBarCodeScannerInterface (from `../node_modules/unimodules-barcode-scanner-interface/ios`)
- UMCameraInterface (from `../node_modules/unimodules-camera-interface/ios`)
- UMConstantsInterface (from `../node_modules/unimodules-constants-interface/ios`)
- "UMCore (from `../node_modules/@unimodules/core/ios`)"
- UMFaceDetectorInterface (from `../node_modules/unimodules-face-detector-interface/ios`)
- UMFileSystemInterface (from `../node_modules/unimodules-file-system-interface/ios`)
- UMFontInterface (from `../node_modules/unimodules-font-interface/ios`)
- UMImageLoaderInterface (from `../node_modules/unimodules-image-loader-interface/ios`)
- UMPermissionsInterface (from `../node_modules/unimodules-permissions-interface/ios`)
- "UMReactNativeAdapter (from `../node_modules/@unimodules/react-native-adapter/ios`)"
- UMSensorsInterface (from `../node_modules/unimodules-sensors-interface/ios`)
- UMTaskManagerInterface (from `../node_modules/unimodules-task-manager-interface/ios`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand All @@ -339,16 +339,16 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
EXAppLoaderProvider:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/expo-app-loader-provider/ios"
path: "../node_modules/expo-app-loader-provider/ios"
EXConstants:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/expo-constants/ios"
path: "../node_modules/expo-constants/ios"
EXErrorRecovery:
:path: !ruby/object:Pathname
path: "../node_modules/expo-error-recovery/ios"
EXFileSystem:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/expo-file-system/ios"
path: "../node_modules/expo-file-system/ios"
EXFont:
:path: !ruby/object:Pathname
path: "../node_modules/expo-font/ios"
Expand All @@ -363,7 +363,7 @@ EXTERNAL SOURCES:
path: "../node_modules/expo-location/ios"
EXPermissions:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/expo-permissions/ios"
path: "../node_modules/expo-permissions/ios"
EXSQLite:
:path: !ruby/object:Pathname
path: "../node_modules/expo-sqlite/ios"
Expand Down Expand Up @@ -428,40 +428,40 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-screens"
UMBarCodeScannerInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-barcode-scanner-interface/ios"
path: "../node_modules/unimodules-barcode-scanner-interface/ios"
UMCameraInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-camera-interface/ios"
path: "../node_modules/unimodules-camera-interface/ios"
UMConstantsInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-constants-interface/ios"
path: "../node_modules/unimodules-constants-interface/ios"
UMCore:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/@unimodules/core/ios"
path: "../node_modules/@unimodules/core/ios"
UMFaceDetectorInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-face-detector-interface/ios"
path: "../node_modules/unimodules-face-detector-interface/ios"
UMFileSystemInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-file-system-interface/ios"
path: "../node_modules/unimodules-file-system-interface/ios"
UMFontInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-font-interface/ios"
path: "../node_modules/unimodules-font-interface/ios"
UMImageLoaderInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-image-loader-interface/ios"
path: "../node_modules/unimodules-image-loader-interface/ios"
UMPermissionsInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-permissions-interface/ios"
path: "../node_modules/unimodules-permissions-interface/ios"
UMReactNativeAdapter:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/@unimodules/react-native-adapter/ios"
path: "../node_modules/@unimodules/react-native-adapter/ios"
UMSensorsInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-sensors-interface/ios"
path: "../node_modules/unimodules-sensors-interface/ios"
UMTaskManagerInterface:
:path: !ruby/object:Pathname
path: "../node_modules/expo/node_modules/unimodules-task-manager-interface/ios"
path: "../node_modules/unimodules-task-manager-interface/ios"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand Down Expand Up @@ -506,7 +506,7 @@ SPEC CHECKSUMS:
RNCMaskedView: dd13f9f7b146a9ad82f9b7eb6c9b5548fcf6e990
RNGestureHandler: 946a7691e41df61e2c4b1884deab41a4cdc3afff
RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c
RNScreens: f5e2ff7ccde2a1bfcf2a48c6fd07fdcf1fd95223
RNScreens: 62284de159bbddba268edd282337afdb8771aaed
UMBarCodeScannerInterface: 3802c8574ef119c150701d679ab386e2266d6a54
UMCameraInterface: 985d301f688ed392f815728f0dd906ca34b7ccb1
UMConstantsInterface: bda5f8bd3403ad99e663eb3c4da685d063c5653c
Expand Down
23 changes: 23 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,30 @@
"@types/react": "^16.9.16",
"@types/react-native": "^0.60.25",
"babel-preset-expo": "^8.0.0",
"detox": "^15.0.0",
"expo-cli": "^3.11.1",
"jest": "^24.9.0",
"typescript": "^3.7.3"
},
"detox": {
"test-runner": "jest",
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ReactNavigationExample.app",
"build": "set -o pipefail; xcodebuild -workspace ios/ReactNavigationExample.xcworkspace -scheme ReactNavigationExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11 Pro"
}
},
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/ReactNavigationExample.app",
"build": "export RCT_NO_LAUNCH_PACKAGER=true; set -o pipefail; xcodebuild -workspace ios/ReactNavigationExample.xcworkspace -scheme ReactNavigationExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11 Pro"
}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"eslint": "^6.7.2",
"eslint-config-satya164": "^3.1.5",
"husky": "^3.0.9",
"jest": "^24.8.0",
"jest": "^24.9.0",
"lerna": "^3.18.4",
"prettier": "^1.19.1",
"typescript": "^3.7.3"
Expand Down
Loading

0 comments on commit fbadea4

Please sign in to comment.