Skip to content

Commit ae2e1bf

Browse files
Automate e2e tests for Android and IOS (#296)
Changing circle ci config to run maestro e2e tests for IOS and Android. Also updated the tests as circle-ci's env variables were changed to use a dedicated workspace for react native tests
1 parent 963e595 commit ae2e1bf

File tree

7 files changed

+98
-39
lines changed

7 files changed

+98
-39
lines changed

.circleci/config.yml

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
# Default VM config to be used for macOS builds
44
macos_config: &macos_config
55
macos:
6-
xcode: 15.3.0
6+
xcode: 16.0.0
77
resource_class: macos.m1.large.gen1
88
shell: /bin/bash --login -eo pipefail
99

@@ -20,7 +20,8 @@ executors:
2020
working_directory: ~/project
2121

2222
orbs:
23-
android: circleci/[email protected]
23+
android: circleci/[email protected]
24+
node: circleci/[email protected]
2425

2526
# Always run job
2627
run_always: &run_always
@@ -55,17 +56,13 @@ jobs:
5556
command: |
5657
corepack enable
5758
yarn install --cwd example
58-
yarn install --cwd example/e2e
5959
yarn install
6060
- save_cache:
6161
key: dependencies-{{ checksum "package.json" }}
6262
paths: node_modules
6363
- save_cache:
6464
key: dependencies-example-{{ checksum "example/package.json" }}
6565
paths: example/node_modules
66-
- save_cache:
67-
key: dependencies-example-e2e-{{ checksum "example/package.json" }}
68-
paths: example/e2e/node_modules
6966
- persist_to_workspace:
7067
root: .
7168
paths: .
@@ -115,18 +112,25 @@ jobs:
115112
JAVA_OPTS: '-Xms512m -Xmx1024m'
116113
executor:
117114
name: android/android-machine
115+
tag: default
118116
working_directory: ~/project
119117
steps:
120118
- checkout:
121119
path: ~/project
120+
- node/install:
121+
node-version: 18.17.0
122122

123123
- attach_workspace:
124124
at: ~/project
125125

126126
- <<: *setup_env_file
127127

128128
- run:
129-
working_directory: example/e2e
129+
name: Install Maestro
130+
command: curl -Ls "https://get.maestro.mobile.dev" | bash
131+
132+
- run:
133+
working_directory: example/test
130134
name: Build android
131135
command: npm run build:android
132136

@@ -141,10 +145,19 @@ jobs:
141145
post-emulator-launch-assemble-command: echo Emulator Started
142146

143147
- run:
144-
working_directory: example/e2e
148+
name: Install app on emulator
149+
command: |
150+
adb install -r ~/project/example/android/app/build/outputs/apk/release/app-release.apk
151+
152+
- run:
153+
working_directory: example/test
145154
name: Run UI Tests
146155
command: npm run test:android
147156

157+
- store_artifacts:
158+
path: ~/.maestro/tests
159+
destination: maestro-tests
160+
148161
# Build the Test App used for UI Testing and save is to the workspace. This allows it to be used by other jobs.
149162
ios-e2e-test:
150163
<<: *macos_config
@@ -155,28 +168,49 @@ jobs:
155168

156169
- <<: *setup_env_file
157170

171+
- run:
172+
working_directory: example/e2e
173+
name: Install Maestro
174+
command: curl -Ls "https://get.maestro.mobile.dev" | bash
175+
158176
- restore_cache:
159177
keys:
160178
- pod-dependencies-{{ checksum "~/project/example/ios/Podfile" }}
161179
- run:
162180
working_directory: example/ios
163181
name: Install Pods
164182
command: pod install
183+
165184
- save_cache:
166185
key: pod-dependencies-{{ checksum "~/project/example/ios/Podfile" }}
167186
paths:
168187
- ~/project/example/ios/Pods
169188

170189
- run:
171-
working_directory: example/e2e
190+
working_directory: example/test
172191
name: Build
173192
command: npm run build:ios
174193

175194
- run:
176-
working_directory: example/e2e
195+
name: Create and boot iPhone 15 simulator
196+
command: |
197+
echo "Creating iPhone 15 simulator with runtime $RUNTIME"
198+
xcrun simctl create "iPhone 15" com.apple.CoreSimulator.SimDeviceType.iPhone-15 $RUNTIME
199+
xcrun simctl boot "iPhone 15" || true
200+
201+
- run:
202+
name: Install app on simulator
203+
command: |
204+
xcrun simctl install booted ~/project/example/test/build/Build/Products/Release-iphonesimulator/IntercomReactNativeExampleUI.app
205+
206+
- run:
207+
working_directory: example/test
177208
name: Run UI Tests
178209
command: npm run test:ios
179210

211+
- store_artifacts:
212+
path: ~/.maestro/tests
213+
destination: maestro-tests
180214

181215
release-to-npm:
182216
executor: default
@@ -224,22 +258,23 @@ workflows:
224258
<<: *run_always
225259
requires:
226260
- install-dependencies
227-
# - android-e2e-test:
228-
# <<: *run_always
229-
# requires:
230-
# - install-dependencies
231-
# - lint
232-
# - typescript
233-
# - unit-tests
234-
# - build-package
235-
# - ios-e2e-test:
236-
# <<: *run_always
237-
# requires:
238-
# - install-dependencies
239-
# - lint
240-
# - typescript
241-
# - unit-tests
242-
# - build-package
261+
- android-e2e-test:
262+
<<: *run_always
263+
requires:
264+
- install-dependencies
265+
- lint
266+
- typescript
267+
- unit-tests
268+
- build-package
269+
- ios-e2e-test:
270+
<<: *run_always
271+
requires:
272+
- install-dependencies
273+
- lint
274+
- typescript
275+
- unit-tests
276+
- build-package
277+
243278
- release-to-npm:
244279
<<: *run_on_release
245280
context:
@@ -250,5 +285,5 @@ workflows:
250285
- typescript
251286
- unit-tests
252287
- build-package
253-
# - ios-e2e-test
254-
# - android-e2e-test
288+
- ios-e2e-test
289+
- android-e2e-test

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ react {
4242
// bundleAssetName = "MyApplication.android.bundle"
4343
//
4444
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
45-
entryFile = file("index.tsx")
45+
entryFile = file("../../index.tsx")
4646
//
4747
// A list of extra flags to pass to the 'bundle' commands.
4848
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle

example/test/maestro/android/open-help-center.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ tags:
55
---
66
- launchApp
77
- tapOn: "Login as an Unidentified User"
8+
- assertVisible:
9+
text: "Present Help Center"
10+
enabled: true
811
- tapOn: "Present Help Center"
9-
- assertVisible: "Help"
10-
- assertVisible: "Untitled Collection"
11-
- tapOn: "Untitled Collection"
12+
- assertVisible: "React Native Test Article"
13+
- tapOn: "React Native Test Article"
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
git appId: com.example.intercomreactnative
1+
appId: com.example.intercomreactnative
22
tags:
33
- android
44
- messenger
55
---
66
- launchApp
77
- tapOn: "Login as an Unidentified User"
8+
- assertVisible:
9+
text: "Present Intercom"
10+
enabled: true
811
- tapOn: "Present Intercom"
9-
- tapOn: "Messenger Apps"
12+
- tapOn: "Messages"
1013

example/test/maestro/ios/open-help-center.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ tags:
55
---
66
- launchApp
77
- tapOn: "Login as an Unidentified User"
8+
- assertVisible:
9+
text: "Present Help Center"
10+
enabled: true
811
- tapOn: "Present Help Center"
9-
- assertVisible: "Help"
10-
- assertVisible: "Untitled collection"
11-
- tapOn: "Untitled collection"
12+
- assertVisible: "React Native Test Article"
13+
- tapOn: "React Native Test Article"

example/test/maestro/ios/open-messenger.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ tags:
55
---
66
- launchApp
77
- tapOn: "Login as an Unidentified User"
8+
- assertVisible:
9+
text: "Present Intercom"
10+
enabled: true
811
- tapOn: "Present Intercom"
9-
- tapOn: "Messenger apps"
10-
12+
- tapOn: "Messages"

example/test/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "intercom-react-native-example-e2e-tests",
3+
"description": "Running",
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"scripts": {
7+
"build:android": "../android/gradlew assembleRelease -Pfoss -p ../android",
8+
"build:ios": "xcodebuild build -workspace ../ios/IntercomReactNativeExample.xcworkspace -scheme IntercomReactNativeExampleUI -configuration Release -sdk iphonesimulator -derivedDataPath ./build",
9+
"test:android": "maestro test ./maestro/android/*.yaml",
10+
"test:ios": "maestro test ./maestro/ios/*.yaml"
11+
},
12+
"keywords": [],
13+
"author": "",
14+
"license": "ISC"
15+
}

0 commit comments

Comments
 (0)