Skip to content

Commit a3da74c

Browse files
authored
chore: fix running example app (#769)
* chore: fix running example app * chore: change babel config * chore: change babel config * chore: change babel config * chore: change babel config * chore: change babel config * chore: change babel config * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: android emulator changes * chore: detox updates * chore: detox updates * chore: detox updates * chore: detox updates * chore: detox updates
1 parent 4f80afa commit a3da74c

22 files changed

+2972
-5078
lines changed

.circleci/config.yml

+41-31
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ jobs:
3030
command: yarn test
3131
name: Jest
3232

33-
# new_arch_ios_build:
34-
# executor:
35-
# name: rn/macos
36-
# xcode_version: '14.0.0'
37-
# steps:
38-
# - checkout
39-
# - run:
40-
# command: yarn install --frozen-lockfile
41-
# name: yarn install
42-
# - run:
43-
# command: cd example && yarn install --frozen-lockfile && cd -
44-
# name: yarn install example
45-
# - run:
46-
# command: (cd example && RCT_NEW_ARCH_ENABLED=1 npx pod-install)
47-
# name: pod install
48-
# - run:
49-
# command: yarn detox:ios:build:release
50-
# name: build app with new arch
33+
# new_arch_ios_build:
34+
# executor:
35+
# name: rn/macos
36+
# xcode_version: '14.0.0'
37+
# steps:
38+
# - checkout
39+
# - run:
40+
# command: yarn install --frozen-lockfile
41+
# name: yarn install
42+
# - run:
43+
# command: cd example && yarn install --frozen-lockfile && cd -
44+
# name: yarn install example
45+
# - run:
46+
# command: (cd example && RCT_NEW_ARCH_ENABLED=1 npx pod-install)
47+
# name: pod install
48+
# - run:
49+
# command: yarn detox:ios:build:release
50+
# name: build app with new arch
5151

5252

5353
e2e_release_ios:
@@ -62,10 +62,10 @@ jobs:
6262
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
6363
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
6464
- rn/ios_simulator_start:
65-
device: 'iPhone 11'
65+
device: 'iPhone 14'
6666
# - rn/yarn_install
6767
- run:
68-
command: yarn install --frozen-lockfile
68+
command: yarn install --frozen-lockfile && npx patch-package
6969
name: yarn install
7070
- run:
7171
command: yarn bundle:ios
@@ -85,34 +85,40 @@ jobs:
8585
executor:
8686
name: android/android-machine
8787
resource-class: large
88-
tag: '2022.01.1'
88+
tag: '2023.04.1'
8989
steps:
9090
- checkout
9191
- run:
9292
command: avdmanager list
9393
name: list avds
94+
- run:
95+
command: sdkmanager --list
96+
name: list sdks
9497
- android/create-avd:
9598
avd-name: TestingAVD
9699
system-image: system-images;android-29;default;x86
97-
additional-args: --device pixel_4_xl
100+
additional-args: --device pixel_3_xl
98101
install: true
102+
background: false
99103
- android/start-emulator:
100104
avd-name: TestingAVD
101105
no-window: true
102-
restore-gradle-cache-prefix: v1a
106+
wait-for-emulator: true
107+
disable-animations: true
108+
restore-gradle-cache-post-emulator-launch: false
103109
post-emulator-launch-assemble-command: "pwd"
104-
- android/disable-animations
110+
# - android/disable-animations
105111
- run:
106112
command: npm install --global yarn
107113
name: install yarn
108114
- run:
109-
command: yarn install --frozen-lockfile
115+
command: yarn install --frozen-lockfile && npx patch-package
110116
name: yarn install
111117
- run:
112118
command: yarn bundle:android
113119
name: bundle js
114120
- run:
115-
command: yarn detox:android:build:release
121+
command: ORG_GRADLE_PROJECT_newArchEnabled=false yarn detox:android:build:release
116122
name: build app for e2e tests
117123
- run:
118124
command: yarn detox:android:test:release
@@ -125,7 +131,7 @@ jobs:
125131
executor:
126132
name: android/android-machine
127133
resource-class: large
128-
tag: '2022.01.1'
134+
tag: '2023.04.1'
129135
steps:
130136
- checkout
131137
- run:
@@ -134,26 +140,30 @@ jobs:
134140
- android/create-avd:
135141
avd-name: TestingAVD
136142
system-image: system-images;android-29;default;x86
137-
additional-args: --device pixel_4_xl
143+
additional-args: --device pixel_3_xl
138144
install: true
145+
background: false
139146
- android/start-emulator:
140147
avd-name: TestingAVD
141148
no-window: true
142-
restore-gradle-cache-prefix: v1a
149+
wait-for-emulator: true
150+
disable-animations: true
151+
restore-gradle-cache-post-emulator-launch: false
143152
post-emulator-launch-assemble-command: "pwd"
144-
- android/disable-animations
145153
- run:
146154
command: npm install --global yarn
147155
name: install yarn
148156
- run:
149-
command: yarn install --frozen-lockfile
157+
command: yarn install --frozen-lockfile && npx patch-package
150158
name: yarn install
151159
- run:
152160
command: yarn bundle:android
153161
name: bundle js
154162
- run:
155163
command: ORG_GRADLE_PROJECT_newArchEnabled=true yarn detox:android:build:release
156164
name: build app for e2e tests
165+
# - android/wait-for-emulator
166+
# - android/disable-animations
157167
- run:
158168
command: yarn detox:android:test:release
159169
name: run e2e tests

.detoxrc.js

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
module.exports = {
2+
testRunner: {
3+
$0: 'jest',
4+
args: {
5+
config: 'example/e2e/jest.config.js',
6+
},
7+
},
8+
devices: {
9+
simulator: {
10+
type: 'ios.simulator',
11+
device: {
12+
type: 'iPhone 14',
13+
},
14+
},
15+
emulator: {
16+
type: 'android.emulator',
17+
utilBinaryPaths: ['example/e2e/test-butler-app.apk'],
18+
device: {
19+
avdName: 'TestingAVD',
20+
},
21+
},
22+
'android.attached': {
23+
type: 'android.attached',
24+
device: {
25+
adbName: '34HDU19716000753',
26+
},
27+
},
28+
},
29+
apps: {
30+
'ios.debug': {
31+
type: 'ios.app',
32+
binaryPath:
33+
'example/ios/build/Build/Products/Debug-iphonesimulator/ReactTestApp.app',
34+
build:
35+
"export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace example/ios/date-time-picker-example.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 14' -scheme date-time-picker-example -configuration Debug -derivedDataPath example/ios/build -UseModernBuildSystem=YES CODE_SIGNING_ALLOWED=NO",
36+
},
37+
'ios.release': {
38+
type: 'ios.app',
39+
binaryPath:
40+
'example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app',
41+
build:
42+
'export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace example/ios/date-time-picker-example.xcworkspace -sdk iphonesimulator -scheme date-time-picker-example -configuration Release -derivedDataPath example/ios/build -UseModernBuildSystem=YES CODE_SIGNING_ALLOWED=NO',
43+
},
44+
'android.debug': {
45+
type: 'android.apk',
46+
binaryPath: 'example/android/app/build/outputs/apk/debug/app-debug.apk',
47+
build:
48+
'export RCT_NO_LAUNCH_PACKAGER=true && (cd example/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug)',
49+
},
50+
'android.release': {
51+
type: 'android.apk',
52+
binaryPath:
53+
'example/android/app/build/outputs/apk/release/app-release.apk',
54+
build:
55+
'export RCT_NO_LAUNCH_PACKAGER=true && (cd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release)',
56+
},
57+
},
58+
configurations: {
59+
'ios.sim.debug': {
60+
app: 'ios.debug',
61+
device: 'simulator',
62+
},
63+
'ios.sim.release': {
64+
app: 'ios.release',
65+
device: 'simulator',
66+
},
67+
'android.emu.debug': {
68+
app: 'android.debug',
69+
device: 'emulator',
70+
},
71+
'android.device.debug': {
72+
app: 'android.debug',
73+
device: 'android.attached',
74+
},
75+
'android.emu.release': {
76+
app: 'android.release',
77+
device: 'emulator',
78+
},
79+
},
80+
artifacts: {
81+
plugins: {
82+
video: {
83+
android: {
84+
size: [1280, 720],
85+
},
86+
},
87+
},
88+
},
89+
};

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
globals: {
55
expect: true,
66
element: true,

babel.config.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
const isLintingOrTesting =
2+
process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'lint';
3+
14
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
3-
}
5+
presets: [
6+
[
7+
'module:metro-react-native-babel-preset',
8+
// this is a workaround for some deeper issue
9+
{useTransformReactJSXExperimental: !isLintingOrTesting},
10+
],
11+
],
12+
};

example/android/app/src/androidTest/java/com/microsoft/reacttestapp/DetoxTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@LargeTest
1616
public class DetoxTest {
1717
@Rule
18-
// Replace 'MainActivity' with the value of android:name entry in
18+
// Replace 'MainActivity' with the value of android:name entry in
1919
// <activity> in AndroidManifest.xml
2020
public ActivityTestRule<com.microsoft.reacttestapp.MainActivity> mActivityRule = new ActivityTestRule<>(com.microsoft.reacttestapp.MainActivity.class, false, false);
2121

@@ -28,4 +28,4 @@ public void runDetoxTests() {
2828

2929
Detox.runTests(mActivityRule, detoxConfig);
3030
}
31-
}
31+
}

example/android/build.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ allprojects {
5353

5454
project.dependencies {
5555
androidTestImplementation('com.wix:detox:+')
56-
// pinning soloader to 0.10.4 fixes problem with detox "couldn't find DSO to load: libhermes.so" https://github.com/wix/Detox/issues/3487
57-
implementation 'com.facebook.soloader:soloader:0.10.4+'
5856
}
5957
}
6058
}

example/android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FLIPPER_VERSION=false
3636

3737
# Enable new architecture, i.e. Fabric + TurboModule - implies USE_FABRIC=1.
3838
# Note that this is incompatible with web debugging.
39-
newArchEnabled=true
39+
#newArchEnabled=true
4040

4141
# Uncomment the line below if building react-native from source
4242
#ANDROID_NDK_VERSION=21.4.7075529

example/app.json

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"android": {
77
"package": "com.datetimepickerexample"
88
},
9+
"ios": {
10+
"bundleIdentifier": "com.datetimepickerexample",
11+
"developmentTeam": ""
12+
},
913
"components": [
1014
{
1115
"appKey": "date-time-picker-example",

example/e2e/Environment.js

-23
This file was deleted.

example/e2e/config.json

-7
This file was deleted.

example/e2e/detoxTest.spec.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ describe('e2e tests', () => {
2424
return isIOS() ? 'spinner' : 'default';
2525
};
2626

27+
beforeAll(async () => {
28+
if (isIOS()) {
29+
await device.launchApp({newInstance: true});
30+
}
31+
}, 300000);
32+
2733
beforeEach(async () => {
2834
if (isIOS()) {
2935
await device.reloadReactNative();
@@ -250,8 +256,7 @@ describe('e2e tests', () => {
250256

251257
it(':android: when component unmounts, dialog is dismissed', async () => {
252258
await elementById('showAndDismissPickerButton').tap();
253-
await wait(1000);
254-
await expect(getDatePickerAndroid()).toExist();
259+
await waitFor(getDatePickerAndroid()).toExist().withTimeout(4000);
255260
await wait(6000);
256261

257262
await expect(getDatePickerAndroid()).not.toExist();

example/e2e/init.js

-6
This file was deleted.

example/e2e/jest.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
maxWorkers: 1,
3+
testTimeout: 120000,
4+
verbose: true,
5+
reporters: ['detox/runners/jest/reporter'],
6+
globalSetup: 'detox/runners/jest/globalSetup',
7+
globalTeardown: 'detox/runners/jest/globalTeardown',
8+
testEnvironment: 'detox/runners/jest/testEnvironment',
9+
};

example/e2e/test-butler-app.apk

130 KB
Binary file not shown.

example/e2e/utils/actions.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ async function userTapsOkButtonAndroid() {
5757
}
5858

5959
async function userDismissesCompactDatePicker() {
60-
await element(by.type('_UIDatePickerContainerView')).tap({
61-
x: 50,
62-
y: 50,
63-
});
60+
await element(by.type('_UIDatePickerContainerView')).tap();
6461
}
6562

6663
module.exports = {

0 commit comments

Comments
 (0)