Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fixed detox tests. #1446

Merged
merged 41 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
104e4c1
build: pin specific expo version.
zhyd1997 Nov 26, 2023
c2e8d11
test: remove listener.
zhyd1997 Nov 26, 2023
78dbdfa
test: pass empty listener.
zhyd1997 Nov 26, 2023
96bf14e
Merge branch 'jhipster:main' into ci/ticket-889-1700974455106
zhyd1997 Dec 1, 2023
200440c
test: jest mock expo.
zhyd1997 Dec 2, 2023
2948cfd
ci: updated config.
zhyd1997 Dec 2, 2023
db086d9
fix: get IOS_DEVICE_NAME from new detox config.
zhyd1997 Dec 2, 2023
051de88
e2e: removed outdated test enviroment config.
zhyd1997 Dec 3, 2023
ff330f4
fix: added sb config in metro.config.js.ejs
zhyd1997 Dec 6, 2023
a88adac
Merge branch 'main' into ci/ticket-889-1700974455106
zhyd1997 Dec 10, 2023
a5ebc51
Merge branch 'main' into ci/ticket-889-1700974455106
zhyd1997 Dec 16, 2023
dea496a
e2e: updated ios device to iPhone 15.
zhyd1997 Dec 16, 2023
dcaa9a2
fix: rewrite reloadApp.
zhyd1997 Dec 16, 2023
0d7fa2d
e2e: use latest expo go sdk.
zhyd1997 Dec 16, 2023
dadd92e
e2e: use iPhone 14 as ios simulator.
zhyd1997 Dec 16, 2023
31cc211
e2e: disable synchronization and close developer menu.
zhyd1997 Dec 17, 2023
1597428
ci: added circle ci config for OAuth app e2e.
zhyd1997 Dec 17, 2023
9c2590f
fix: removed expo-detox-hook deps.
zhyd1997 Dec 17, 2023
0ed0dc1
e2e: bypass save password prompt.
zhyd1997 Dec 18, 2023
7433646
e2e: reload app with new instance.
zhyd1997 Dec 18, 2023
b50a2ac
fix: import HeaderBackButton from '@react-navigation/elements'
zhyd1997 Dec 19, 2023
e5a4592
ci: removed circle ci integration.
zhyd1997 Dec 19, 2023
02fe277
try to change abi version
mshima Dec 19, 2023
e465372
Update utils.js.ejs
mshima Dec 19, 2023
d89acdd
Merge branch 'main' into ci/ticket-889-1700974455106
zhyd1997 Dec 21, 2023
4bd9c03
e2e: ignore failing tests.
zhyd1997 Dec 21, 2023
ddff361
e2e: skip failing tests.
zhyd1997 Dec 21, 2023
1853a4e
Merge branch 'main' into ci/ticket-889-1700974455106
zhyd1997 Dec 23, 2023
fde2c17
e2e: enabled login screen test.
zhyd1997 Dec 23, 2023
4175235
e2e: enabled setting screen test.
zhyd1997 Dec 23, 2023
2fea726
ci: setup Xcode 15.
zhyd1997 Dec 23, 2023
0a60cc6
e2e: upgraded simulator from iPhone 14 with iPhone 15.
zhyd1997 Dec 23, 2023
563748b
ci: setup JwtHealthPointsApp circle ci config.
zhyd1997 Dec 23, 2023
ecc4e79
e2e: enabled change password test.
zhyd1997 Dec 23, 2023
51ed7e4
e2e: wait 2s to open drawer. (#7)
zhyd1997 Dec 23, 2023
fb9b3dd
e2e: enabled chat screen test. (#9)
zhyd1997 Dec 23, 2023
e034d30
Merge branch 'main' into ci/ticket-889-1700974455106
mshima Jan 3, 2024
e41073c
Merge branch 'main' into ci/ticket-889-1700974455106
zhyd1997 Feb 21, 2024
df1dd43
bump react-native
mshima Feb 22, 2024
5133f0e
disable change passa
mshima Feb 22, 2024
03d824c
add iOS summary for ci auto-merge requirement
mshima Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion generators/app/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ const files = {
condition: generator => generator.context.detox === true,
templates: [
'.detoxrc.json',
'e2e/environment.js',
'e2e/config.json',
'e2e/home-screen.spec.js',
'e2e/utils.js',
Expand Down
4 changes: 2 additions & 2 deletions generators/app/resources/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"react-native-web": "~0.19.6"
},
"devDependencies": {
"expo": "49.0.6",
"expo-template-blank-typescript": "49.0.14",
"expo": "~49.0.15",
"expo-template-blank-typescript": "49.0.23",
"jest-expo": "^49.0.0",
"typescript": "^5.1.3"
}
Expand Down
26 changes: 21 additions & 5 deletions generators/app/templates/.detoxrc.json.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
{
"configurations": {
"ios.sim.release": {
"device": "simulator",
"app": "myApp.ios",
}
},
"apps": {
"myApp.ios": {
"type": "ios.app",
"binaryPath": "e2e/Exponent.app",
},
},
"devices": {
"simulator": {
"type": "ios.simulator",
"device": {
"type": "iPhone 12"
}
}
"type": "iPhone 12",
},
},
},
"artifacts": {
"rootDir": ".artifacts",
Expand All @@ -20,6 +31,11 @@
}
}
},
"test-runner": "jest",
"runner-config": "./e2e/config.json"
"testRunner": {
"$0": "jest",
"args": {
"config": "./e2e/config.json"
},
"_": ["e2e"]
}
}
10 changes: 7 additions & 3 deletions generators/app/templates/e2e/config.json.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"testEnvironment": "./environment",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considering rewrite reloadApp, or maybe occur an issue: wix/Detox#3992

"rootDir": "..",
"testMatch": ["<rootDir>/e2e/**/*.spec.js"],
"reporters": ["detox/runners/jest/reporter"],
"testEnvironment": "detox/runners/jest/testEnvironment",
"globalSetup": "detox/runners/jest/globalSetup",
"globalTeardown": "detox/runners/jest/globalTeardown",
"testRunner": "jest-circus/runner",
"testTimeout": 300000,
"testRegex": "\\.spec\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"maxWorkers": 1,
"verbose": true
}
21 changes: 0 additions & 21 deletions generators/app/templates/e2e/environment.js.ejs

This file was deleted.

4 changes: 2 additions & 2 deletions generators/app/templates/e2e/scripts/setup.sh.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ echo 'Checking for Expo App...'
./e2e/scripts/download-expo.sh

# get ios device name from detox config
IOS_DEVICE_NAME=$(cat .detoxrc.json | jq -rc '.configurations | .[] | .device | .type')
IOS_DEVICE_NAME=$(cat .detoxrc.json | jq -rc '.devices | .[] | .device | .type')
# get simulator matching that name
DEVICE_ID=$(xcrun simctl list devices -j | jq -rc ".[] | .[] | .[] | select( .name == \"$IOS_DEVICE_NAME\" ) | select( .isAvailable == true ) | .udid")

Expand All @@ -18,7 +18,7 @@ xcrun simctl install $DEVICE_ID e2e/Exponent.app

echo 'Fetching App Bundle from Expo Packager...'
# warm up the app - prebuild the bundle with dev=false and minify=true, otherwise it times out at start of detox test
rep=$(curl -fs "http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=false&hot=false&minify=true")
rep=$(curl -fs "http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=false&hot=false&minify=true")
status=$?

if [ "$status" -ne 0 ]; then
Expand Down
6 changes: 3 additions & 3 deletions generators/app/templates/e2e/utils.js.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const DetoxExpoHelpers = require('@ruddell/detox-expo-helpers');
const { device } = require('detox');

const username = process.env.E2E_USERNAME || 'user';
const password = process.env.E2E_PASSWORD || 'user';
const expoPublishedUrl = process.env.E2E_EXPO_URL || 'exp://localhost:19000';
const expoPublishedUrl = process.env.E2E_EXPO_URL || 'exp://localhost:8081';

const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

Expand Down Expand Up @@ -108,7 +108,7 @@ const waitForElementToBeVisibleById = async (elementId, timeout = 5000) => {
const reloadApp = async (bailOnFailure) => {
try {
// disabling Detox synchronization - broken for Expo apps in Detox 18+, speeds up tests at the cost of using waitFor
await DetoxExpoHelpers.reloadApp({ url: expoPublishedUrl, launchArgs: { detoxEnableSynchronization: false } });
await device.launchApp({ url: expoPublishedUrl, launchArgs: { detoxEnableSynchronization: false } });
// if you eject from expo, you should replace the line above with:
// device.reloadReactNative()
await waitForElementToBeVisibleById('homeScreen', 15000);
Expand Down
1 change: 0 additions & 1 deletion generators/app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
},
"devDependencies": {
"@react-native-community/eslint-config": "3.2.0",
"@ruddell/detox-expo-helpers": "0.7.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it because it contains outdated @expo/webpack-config and it is not maintained no longer.

"@storybook/addons": "7.6.1",
"@storybook/react-native": "6.5.7",
"@storybook/theming": "7.6.1",
Expand Down
1 change: 0 additions & 1 deletion generators/app/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"buffer": "REPLACE_WITH_VERSION",
<%_ if (context.detox) { _%>
"detox": "REPLACE_WITH_VERSION",
"@ruddell/detox-expo-helpers": "REPLACE_WITH_VERSION",
"expo-detox-hook": "REPLACE_WITH_VERSION",
"jest-circus": "REPLACE_WITH_VERSION",
<%_ } _%>
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/test/setup.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ jest
.mock('@storybook/react-native', () => {
return { getStorybookUI: jest.fn(), configure: jest.fn() }
})
// https://github.com/expo/expo/issues/23591#issuecomment-1652548059
.mock('expo-font')
.mock('expo-asset')
2 changes: 1 addition & 1 deletion lib/patch-babel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function patchBabel() {
this.patchInFile('babel.config.js', {
after: 'presets',
insert: "plugins: ['react-native-reanimated/plugin'],",
insert: "plugins: ['@babel/plugin-transform-export-namespace-from', 'react-native-reanimated/plugin'],",
ignoreIfContains: 'react-native-reanimated',
});
}
Expand Down
1 change: 0 additions & 1 deletion test/expected-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ const expectedFiles = {
],
detox: [
'.detoxrc.json',
'e2e/environment.js',
'e2e/config.json',
'e2e/home-screen.spec.js',
'e2e/utils.js',
Expand Down
3 changes: 3 additions & 0 deletions test/scripts/generate-react-native-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ else
--defaults --no-insight --skip-git
fi

# pin specific version of expo
npm i [email protected]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue in the latest expo, which mean e2e will fails in the local env as well:

Screenshot 2023-12-03 at 10 44 05

expo/expo#25551

Copy link
Contributor Author

@zhyd1997 zhyd1997 Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it failed with downgraded `expo`: Screenshot 2023-12-03 at 19 47 48

Copy link
Contributor Author

@zhyd1997 zhyd1997 Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with the latest `expo`: Screenshot 2023-12-03 at 19 51 51

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recorded video in CI:
test.mp4

# list files
ls -al
2 changes: 1 addition & 1 deletion test/scripts/run-detox-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ npm run start:e2e &
# verify the npm packager has started (takes less time than the backend, so should not be an issue)
retryCount=5
maxRetry=60
httpUrl="http://localhost:19000"
httpUrl="http://localhost:8081"
rep=$(curl -fv "$httpUrl")
status=$?
while [ "$status" -ne 0 ] && [ "$retryCount" -le "$maxRetry" ]; do
Expand Down
Loading