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

The event "Network Request" is taking place with object -ios #3443

Closed
chamile opened this issue Jun 10, 2022 · 19 comments
Closed

The event "Network Request" is taking place with object -ios #3443

chamile opened this issue Jun 10, 2022 · 19 comments

Comments

@chamile
Copy link

chamile commented Jun 10, 2022

Description

I have a Sign-in button that it calls an API.
So whan I run await element(by.text('Sign in')).tap();

it navigates to the corresponding page after calling the API request but the test hangs and waits without completing the test.

image

Code

/* eslint-disable no-undef */
const { execSync } = require('child_process');

const OPTIONS = {
  timeout: 10000,
  killSignal: 'SIGKILL',
};
describe('screenshot', () => {
  beforeAll(async () => {
    await device.launchApp();
  });

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

  it('should take screenshot', async () => {
    const fileName = 'screenshot.png';

    if (device.getPlatform() === 'android') {
      execSync(`adb shel screencap /sdcard/${fileName}`);
      execSync(
        `adb pull /sdcard/${fileName} $(pwd)/android/fastlane/metadata/android/en-US/images/phoneScreenshots`
      );
    } else {
      execSync(
        `xcrun simctl io booted screenshot $(pwd)/fastlane/screenshots/screenshot.png`,
        OPTIONS
      );
      await element(by.text('Show more options')).tap();
      execSync(
        `xcrun simctl io booted screenshot $(pwd)/fastlane/screenshots/screenshot1.png`,
        OPTIONS
      );
      await element(by.text('Username & Password')).tap();
      execSync(
        `xcrun simctl io booted screenshot $(pwd)/fastlane/screenshots/screenshot2.png`,
        OPTIONS
      );
      await element(by.id('testID-userName')).typeText('test');
      await element(by.id('testID-password')).typeText('test');
      execSync(
        `xcrun simctl io booted screenshot $(pwd)/fastlane/screenshots/screenshot3.png`,
        OPTIONS
      );
      await element(by.text('Sign in')).tap();
    }
  });
});

Your environment

Detox version: 19.7.1
React Native version: 0.62.2
Node version: v16.11.1
Device model:
iOS version: 13
macOS version: 11.6
Xcode version: 13.0
Test-runner jest-circus

@chamile chamile changed the title The event "Network Request" is taking place with object The event "Network Request" is taking place with object -ios Jun 10, 2022
@d4vidi
Copy link
Collaborator

d4vidi commented Jun 12, 2022

@chamile you need to look into why that network request doesn't get replied to.

On a different matter, have you considered using Detox's API for taking screenshots?

@github-actions
Copy link

This issue appears to be a general usage or support question.
In order to get help, please either ask a question on Stack Overflow with the detox tag, or simply join our Discord.
Feel free to post your Stack Overflow question here for more visibility! We'll take a look at it ASAP.
For more information about our policy on issues, refer to this discussion.

@mgithubmessier
Copy link

Damn, I'm running into this same issue, @chamile you ever figure this one out?

@johanndeswardt
Copy link

I'm also having issues with this.

detoxURLBlacklistRegex and setURLBlacklist do not seem to actually do anything. My tests are not running because synchronization is being prevented because of in-flight requests to Launch Darkly.

@asafkorem
Copy link
Contributor

@johanndeswardt Could you please copy here the setURLBlacklist call you've tried?

@asafkorem
Copy link
Contributor

or the launch-app command with the detoxURLBlacklistRegex argument

@OrLevy23
Copy link

OrLevy23 commented Nov 27, 2022

Hey, i've just came across this issue while trying to implement detox on our app
image

The event "Network Request" is taking place with object: "URL: “https://clientstream.launchdarkly.com/meval/****”".
• Run loop "Main Run Loop" is awake.

any ideas on how to solve it?

@menttys
Copy link

menttys commented Dec 6, 2022

Exactly the same issue as @OrLevy23, any findings about it?

@NicholasBoccuzzi
Copy link

@OrLevy23 @menttys -- did either of you figure this out using a Launch Darkly link?

@d4vidi
Copy link
Collaborator

d4vidi commented Feb 26, 2023

@OrLevy23 @NicholasBoccuzzi @menttys @chamile Please allow for testing out this new release with a related fix - https://github.com/wix/Detox/releases/tag/20.3.0

@GittyAjay
Copy link

GittyAjay commented Mar 21, 2023

I am still getting this error in the updated detox version ("detox": "^20.5.0")

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 (<OS_dispatch_queue_main: com.apple.main-thread>)".
• The event "Network Request" is taking place with object: "URL: “https://api-dev.gigflex.com:8088/socket/501/o2tr5ber/xhr_streaming?t=1679374218301”".

`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)

10:22:08.821 detox[8542] E Command failed with exit code = 1:
jest --config e2e/jest.config.js

Does anyone have any idea how can i resolve this? @d4vidi @mgithubmessier @menttys @OrLevy23 @chamile

@nikolal
Copy link

nikolal commented May 9, 2023

I have the same issue:

detoxURLBlacklistRegex and setURLBlacklist do not seem to actually do anything.

The event "Network Request" is taking place with object: "URL: “https://data.emb-api.com/v1/log/events”".

I tried:

await device.setURLBlacklist(['.*data.emb-api.com.*'])

and

beforeAll(async () => {
  await device.launchApp({
    launchArgs: {
      detoxURLBlacklistRegex: getDetoxURLBlacklistRegexFromDomains(domains),
    },
  })
})

const domains = [
  'data.emb-api.com'
]

const getDetoxURLBlacklistRegexFromDomains = domains =>
  '(' + domains.map(domain => `\\".*${domain}.*\\"`).join(',') + ')'

"detox": "^20.6.0",

@gmferraz
Copy link

Same issue as @OrLevy23. Any news?

@vm-agnislav
Copy link

We have the same issue with LaunchDarkly on the latest detox version. Any updates on it? @d4vidi

@KaterinaUK
Copy link

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

@zfolwick
Copy link

zfolwick commented Dec 5, 2023

I just had this same issue:

• The event "Network Request" is taking place with object: "URL: “https://clients3.google.com/generate_204?_=1701807425591”".

I rarely restart my simulators, so running ps -ef | grep detox showed a process that appeared to have gone stale. I killed the process with kill 42843 and re-ran the tests and that seemed to have fixed it. See below (note the "??" indicating even the OS has forgotten how long it's been around).

Screenshot 2023-12-05 at 12 21 18 PM

@SwetaTanwar
Copy link

I was able to make it work by using detoxURLBlacklistRegex in launchArgs. Make sure to properly pass the url

beforeAll(async () => {
    await device.launchApp({
      newInstance: true,
      launchArgs: {
        detoxURLBlacklistRegex:
          '\\("^https://yourURL.com/*"\\)',
      },
    });
});

@yusinto
Copy link

yusinto commented Apr 25, 2024

We use this internally and should work:

  beforeAll(async () => {
    await device.launchApp({
      newInstance: true,
      launchArgs: {
        detoxURLBlacklistRegex: '\\("^https://clientstream.launchdarkly.com/meval"\\)',
      },
    });
  });

@dominictobias
Copy link

We use this internally and should work:

  beforeAll(async () => {
    await device.launchApp({
      newInstance: true,
      launchArgs: {
        detoxURLBlacklistRegex: '\\("^https://clientstream.launchdarkly.com/meval"\\)',
      },
    });
  });

Life saver. I don't get how they made LD network requests so problematic. They also break Android entirely at least on the simulator :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests