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

fix(CI): fix Android E2E Events test #1898

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion Example/e2e/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { device } from 'detox';

beforeAll(async () => {
await device.launchApp();
await device.launchApp({
launchArgs: {
isDetox: true,
},
});
});

afterAll(async () => {
Expand Down
3 changes: 2 additions & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react": "18.2.0",
"react-native": "0.72.4",
"react-native-gesture-handler": "^2.12.1",
"react-native-launch-arguments": "^4.0.1",
"react-native-restart": "^0.0.27",
"react-native-safe-area-context": "^4.7.1",
"react-native-screens": "link:../",
Expand All @@ -36,9 +37,9 @@
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/jest": "^29.2.5",
"@types/react": "^18.0.24",
"@types/react-native": "0.72.2",
"@types/jest": "^29.2.5",
"@types/react-native-restart": "^0.0.0",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.3.1",
Expand Down
18 changes: 13 additions & 5 deletions Example/src/shared/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ViewStyle,
} from 'react-native';
import { nanoid } from 'nanoid/non-secure';
import { LaunchArguments } from 'react-native-launch-arguments';

interface ToastProps {
index: number;
Expand All @@ -18,7 +19,7 @@ interface ToastProps {
remove: (_: string) => void;
}

const DISAPPEAR_AFTER = 40 * 1000; // 40 x 1000 ms -> 40 s
const DISAPPEAR_AFTER = 10 * 1000; // 10 x 1000 ms -> 10 s

const Toast = ({
index,
Expand All @@ -28,11 +29,18 @@ const Toast = ({
style = {},
remove,
}: ToastProps): JSX.Element => {
const launchArgs = LaunchArguments?.value();

useEffect(() => {
const timer = setTimeout(() => {
remove(id);
}, DISAPPEAR_AFTER);
return () => clearTimeout(timer);
// Unfortunately, sometimes Detox tests are failing because the specific toast
// has been removed too suddenly. On detox tests, we're disabling
// removing the toasts.
if (!launchArgs.isDetox) {
const timer = setTimeout(() => {
remove(id);
}, DISAPPEAR_AFTER);
return () => clearTimeout(timer);
}
}, []);

return (
Expand Down
5 changes: 5 additions & 0 deletions Example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6705,6 +6705,11 @@ react-native-iphone-x-helper@^1.3.0:
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010"
integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg==

react-native-launch-arguments@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/react-native-launch-arguments/-/react-native-launch-arguments-4.0.1.tgz#6d83c05c8de948db5eed8e75fbf76c28431b0c2d"
integrity sha512-sP2Vd+IEtApGiSDboyx8Dqnjj6IlPRA/M8KEoip4r5gidOvGcF/JGVJh9kIlgAchXheH7SWXvtmgvP0dJopikg==

react-native-restart@^0.0.27:
version "0.0.27"
resolved "https://registry.yarnpkg.com/react-native-restart/-/react-native-restart-0.0.27.tgz#43aa8210312c9dfa5ec7bd4b2f35238ad7972b19"
Expand Down
Loading