Skip to content

Commit 6349b98

Browse files
authored
fix: Fix Detox e2e tests broken after 0.73 update. (#366)
Detox was broken after upgrading the example app to RN0.73. The error was very cryptic and the solution equally so: ``` [CP-User] [Hermes] Replace Hermes for the right configuration, if needed ``` Solution: Delete `ios/.xcode.env.local`. facebook/react-native#42112 (comment)
1 parent 03a2d2f commit 6349b98

File tree

5 files changed

+82
-11
lines changed

5 files changed

+82
-11
lines changed

packages/sdk/react-native/example/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,5 @@ MOBILE_KEY=abcdef12456
5252
4. In the example folder, on a terminal:
5353

5454
```shell
55-
yarn && yarn expo-prebuild && yarn start
56-
```
57-
58-
5. Still in the example folder but on another terminal:
59-
60-
```shell
61-
yarn detox-ios
55+
yarn test
6256
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
echo "===== Installing all dependencies"
4+
yarn
5+
6+
echo "===== Building native code"
7+
yarn expo-prebuild
8+
9+
# HACK: This is needed to solve xcode build error:
10+
# "[CP-User] [Hermes] Replace Hermes for the right configuration, if needed"
11+
# https://github.com/facebook/react-native/issues/42112#issuecomment-1884536225
12+
echo "===== Delete .xcode.env.local"
13+
rm -rf ./ios/.xcode.env.local
14+
15+
echo "===== Start metro in background"
16+
yarn start &
17+
18+
echo "===== Run ios tests"
19+
yarn detox-ios
20+
21+
echo "===== Exit"
22+
kill -9 $(lsof -t -i:8081)

packages/sdk/react-native/example/e2e/starter.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ describe('Example', () => {
1515
// await device.reloadReactNative();
1616
// });
1717

18+
afterAll(async () => {
19+
await device.terminateApp();
20+
});
21+
1822
test('app loads and renders correctly', async () => {
1923
await expect(element(by.text(/welcome to launchdarkly/i))).toBeVisible();
2024
await expect(element(by.text(/my-boolean-flag-1: false/i))).toBeVisible();

packages/sdk/react-native/example/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"postinstall": "yarn link-dev",
2020
"detox-build-ios": "detox build -c ios.sim.debug",
2121
"detox-run-ios": "detox test -c ios.sim.debug",
22-
"detox-ios": "yarn detox-build-ios && yarn detox-run-ios"
22+
"detox-ios": "yarn detox-build-ios && yarn detox-run-ios",
23+
"test": "./build-run-detox.sh"
2324
},
2425
"dependencies": {
2526
"@react-native-async-storage/async-storage": "^1.21.0",
@@ -37,7 +38,7 @@
3738
"@types/node": "^20.10.5",
3839
"@types/react": "~18.2.55",
3940
"@types/react-native-dotenv": "^0.2.1",
40-
"detox": "^20.14.7",
41+
"detox": "^20.17.1",
4142
"jest": "^29.7.0",
4243
"ts-jest": "^29.1.1",
4344
"typescript": "^5.2.2"

packages/sdk/react-native/example/yarn.lock

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4851,7 +4851,7 @@ __metadata:
48514851
languageName: node
48524852
linkType: hard
48534853

4854-
"detox@npm:*, detox@npm:^20.14.7":
4854+
"detox@npm:*":
48554855
version: 20.14.7
48564856
resolution: "detox@npm:20.14.7"
48574857
dependencies:
@@ -4901,6 +4901,56 @@ __metadata:
49014901
languageName: node
49024902
linkType: hard
49034903

4904+
"detox@npm:^20.17.1":
4905+
version: 20.17.1
4906+
resolution: "detox@npm:20.17.1"
4907+
dependencies:
4908+
ajv: ^8.6.3
4909+
bunyan: ^1.8.12
4910+
bunyan-debug-stream: ^3.1.0
4911+
caf: ^15.0.1
4912+
chalk: ^4.0.0
4913+
child-process-promise: ^2.2.0
4914+
execa: ^5.1.1
4915+
find-up: ^5.0.0
4916+
fs-extra: ^11.0.0
4917+
funpermaproxy: ^1.1.0
4918+
glob: ^8.0.3
4919+
ini: ^1.3.4
4920+
jest-environment-emit: ^1.0.5
4921+
json-cycle: ^1.3.0
4922+
lodash: ^4.17.11
4923+
multi-sort-stream: ^1.0.3
4924+
multipipe: ^4.0.0
4925+
node-ipc: 9.2.1
4926+
proper-lockfile: ^3.0.2
4927+
resolve-from: ^5.0.0
4928+
sanitize-filename: ^1.6.1
4929+
semver: ^7.0.0
4930+
serialize-error: ^8.0.1
4931+
shell-quote: ^1.7.2
4932+
signal-exit: ^3.0.3
4933+
stream-json: ^1.7.4
4934+
strip-ansi: ^6.0.1
4935+
telnet-client: 1.2.8
4936+
tempfile: ^2.0.0
4937+
trace-event-lib: ^1.3.1
4938+
which: ^1.3.1
4939+
ws: ^7.0.0
4940+
yargs: ^17.0.0
4941+
yargs-parser: ^21.0.0
4942+
yargs-unparser: ^2.0.0
4943+
peerDependencies:
4944+
jest: 29.x.x || 28.x.x || ^27.2.5
4945+
peerDependenciesMeta:
4946+
jest:
4947+
optional: true
4948+
bin:
4949+
detox: local-cli/cli.js
4950+
checksum: 4c12b20e2adfff650f39e21d84028dfe1941370a24f5d9a7c59cb1742d849e7448f513a52200ab22507ece1199f8cf16f049760235ac5d450d22dca4db13bb8b
4951+
languageName: node
4952+
linkType: hard
4953+
49044954
"diff-sequences@npm:^29.6.3":
49054955
version: 29.6.3
49064956
resolution: "diff-sequences@npm:29.6.3"
@@ -8953,7 +9003,7 @@ __metadata:
89539003
"@types/node": ^20.10.5
89549004
"@types/react": ~18.2.55
89559005
"@types/react-native-dotenv": ^0.2.1
8956-
detox: ^20.14.7
9006+
detox: ^20.17.1
89579007
expo: ~50.0.6
89589008
expo-splash-screen: ~0.26.4
89599009
expo-status-bar: ~1.11.1

0 commit comments

Comments
 (0)