Skip to content

Commit

Permalink
ci: retrying detox if not working
Browse files Browse the repository at this point in the history
  • Loading branch information
oscb committed Nov 30, 2023
1 parent d10c8dc commit 8781866
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
43 changes: 41 additions & 2 deletions examples/AnalyticsReactNativeExample/e2e/main.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@ const { element, by, device } = require('detox');

import { startServer, stopServer } from './mockServer';
import { setupMatchers } from './matchers';
import { retry } from 'ts-retry-promise'

const launchApp = async (
launchArgs = {
newInstance: true,
launchArgs: {
detoxPrintBusyIdleResources: 'YES',
},
}
) => {
await retry(
async () => {
try {
await device.launchApp(launchArgs)
} catch (error) {
error.message = `Failed to launch app with error: ${error.message}`
throw error
}
},
{ retries: 5, delay: 10 * 1000, timeout: 30 * 10000 }
).then(async () => {
await device.setURLBlacklist(['.*blockchain-api-dot-celo-mobile-alfajores.*'])
})
}

const reloadReactNative = async () => {
await retry(
async () => {
try {
await device.reloadReactNative()
} catch (error) {
// eslint-disable-next-line no-console
console.error('Failed to reload react native with error', error)
await launchApp()
}
},
{ retries: 5, delay: 10 * 1000, timeout: 30 * 10000 }
)
}

describe('#mainTest', () => {
const mockServerListener = jest.fn();
Expand All @@ -16,7 +55,7 @@ describe('#mainTest', () => {

beforeAll(async () => {
await startServer(mockServerListener);
await device.launchApp();
await launchApp();
setupMatchers();
});

Expand All @@ -29,7 +68,7 @@ describe('#mainTest', () => {

beforeEach(async () => {
mockServerListener.mockReset();
await device.reloadReactNative();
await reloadReactNative();
});

afterAll(async () => {
Expand Down
1 change: 1 addition & 0 deletions examples/AnalyticsReactNativeExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"react-test-renderer": "18.2.0",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.3",
"ts-retry-promise": "^0.7.1",
"typescript": "^5.2.2"
},
"engines": {
Expand Down
8 changes: 8 additions & 0 deletions examples/AnalyticsReactNativeExample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2954,6 +2954,7 @@ __metadata:
react-test-renderer: "npm:18.2.0"
rimraf: "npm:^3.0.2"
ts-jest: "npm:^29.0.3"
ts-retry-promise: "npm:^0.7.1"
typescript: "npm:^5.2.2"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -10022,6 +10023,13 @@ __metadata:
languageName: node
linkType: hard

"ts-retry-promise@npm:^0.7.1":
version: 0.7.1
resolution: "ts-retry-promise@npm:0.7.1"
checksum: 2288f3c45ddb43b55317d02567a1467f307910796b0b44dfc5f88223b5459a6aebf9dac9a67d8680175d6f279d560ad07eb7bed625fc64684db3093708882b91
languageName: node
linkType: hard

"tslib@npm:^1.8.1":
version: 1.14.1
resolution: "tslib@npm:1.14.1"
Expand Down

0 comments on commit 8781866

Please sign in to comment.