wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.17k stars 1.92k forks source link

The app is busy with the following tasks #3992

Closed GittyAjay closed 1 year ago

GittyAjay commented 1 year ago

Description

The app is busy with the following tasks: • Run loop "Main Run Loop" is awake. • The event "Network Request" is taking place with object: "URL: “https://api-dev.gigflex.com:8088/socket/347/oxxy2uxi/xhr_streaming?t=1679374217817”". • There are 1 work items pending on the dispatch queue: "Main Queue ()". • The event "Network Request" is taking place with object: "URL: “https://api-dev.gigflex.com:8088/socket/501/o2tr5ber/xhr_streaming?t=1679374218301”".

Code

`import { device } from 'detox'; describe('App Test', () => {

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

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

it('should have login screen', async () => {

await expect(element(by.id('login-container'))).toBeVisible();

}); });`

and it ends with error

FAIL e2e/starter.test.js (124.849 s) App Test ✕ should have login screen (2 ms)

● App Test › should have login screen

thrown: "Exceeded timeout of 120000 ms for a hook. Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

2 | describe('App Test', () => { 3 |

4 | beforeAll(async () => { | ^ 5 | await device.launchApp(); 6 | }); 7 |

at beforeAll (e2e/starter.test.js:4:5) at Object.describe (e2e/starter.test.js:2:1)

Your environment

Detox version: 20.5.0 React Native version: 0.64.1 Node version: 19.7.0 Device model: Iphone-12 OS: macos 11.6.7 Test-runner: jest

asafkorem commented 1 year ago

Hi @GittyAjay, it seems like there's a network request that doesn't end and your test reaches timeout. The test cannot continue until the app is idle, which is part of our synchronization mechanism.

You can exclude this network request from being synchronized using device.setURLBlacklist([urls]) API. See our documentation for that.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

stale[bot] commented 1 year ago

The issue has been closed for inactivity.

abdymm commented 1 year ago

hi @GittyAjay are you able to fix this issue?

tiagoacastro commented 1 year ago

Any updates on a fix for this? @asafkorem I tried to do as you said but since the execution is stuck on the launchApp I can't blacklist the urls.

KaterinaUK commented 1 year ago

@asafkorem Can I please ask to reopen this issue? Many people still have the same problem! Even after trying what you suggested.

grenos commented 11 months ago

It's definitely an onging issue, we have it with the following specs:

"react-native": "0.72.6",
"detox": "^20.13.1",

EDIT Forgot to mentions that this only happens on iOS

noomorph commented 11 months ago

The issue that OP raised is usually fixed by ignoring certain regexps, e.g.:

https://github.com/mendix/native-widgets/blob/d62cdc803ce1087840f6a20f06db7315b1cb8241/detox/src/helpers.ts#L12

Your app may be busy with any tasks, not necessarily network requests. Specifically for the always-running network requests like socket connections, see the example above.

KaterinaUK commented 11 months ago

I actually found the fix @grenos try this solution (replace url link to your actual network call link): describe('Check for Login Screen', () => { beforeAll(async () => { await device.launchApp({ newInstance: true, launchArgs: { detoxURLBlacklistRegex: '\("https://typeYourNetworkCallHere.com/*")' }, permissions: { notifications: 'YES', userTracking: 'YES' }, }) })

MetodievIvaylo commented 7 months ago

Sometimes the problem comes from a front-end process like endless animation. I was able to bypass it by disabling the device synchronization temporarily.

await device.disableSynchronization()

// action you want to execute
// ex.
await button.tap()

await device.enableSynchronization()