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

firebase snapshot listener blocks detox #4029

Closed
2 tasks done
tmatsuo opened this issue Apr 26, 2023 · 4 comments
Closed
2 tasks done

firebase snapshot listener blocks detox #4029

tmatsuo opened this issue Apr 26, 2023 · 4 comments

Comments

@tmatsuo
Copy link

tmatsuo commented Apr 26, 2023

What happened?

We're developing Expo Go bare workflow project. Simple e2e test works, but if the screen involves firebase snapshot listener, detox thinks the app isn't ready with the following message so that the test timeouts.

15:03:04.350 detox[51421] i ws-client:APP_STATUS The app is busy with the following tasks:                                                                         
• 1 network requests with URLs:                                                                                                                                    
  - URL #1: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?gsessionid=.....

It also happens with ios.

We're using firebase@9.2.0 with the following code:

import { doc, onSnapshot } from 'firebase/firestore';

  useEffect(() => {
    const messageRef = doc(firestore, 'Message', 'hello');
    const unsubscribe = onSnapshot(messageRef, (snapshot) => {
      const m = snapshot.get('message');
      if (m) {
        setMessage(m);
      }
    });
    return () => unsubscribe();
  }, []);

What was the expected behaviour?

I expect we can test such screens.

Presumably any other websockets or long polling requests are considered to be "busy". Does it make sense to have a whitelist for certain URLs?

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

I put the minimum repro project at:

https://github.com/tmatsuo/detox-expo-bare-firebase-repro

This is not from the Detox Template project (expo go and prebuild), but I think I successfully setup Detox because the commit a44a5cdd57fb611d8e863c7cb4de949e722b6957 has a passing Detox test.

Android detox build

npm run pre-e2e-android

Android detox run

npm run e2e-android

Ios detox build:

npm run pre-e2e-ios

Ios detox run:

npm run e2e-ios

In what environment did this happen?

Detox version: 20.7.0
React Native version: 0.70.8
Has Fabric (React Native's new rendering system) enabled: (yes/no) I don't think so
Node version: 16.19.1
Device model: Pixel4 Emulator with API 31
Android version: API 31
Test-runner (select one): jest 29.5.0

Detox logs

Sorry it seems like the detox log was too long to paste.

Device logs

Sorry it seems like the device log was too long to paste.

More data, please!

No response

@marcelobarbosaO
Copy link

the same problem here

@stale
Copy link

stale bot commented Jul 15, 2023

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.

@asafkorem
Copy link
Contributor

asafkorem commented Jul 17, 2023

Hey @tmatsuo @marcelobarbosaO,
This API will help to avoid handling the firebase listener as a busy resource: https://wix.github.io/Detox/docs/next/api/device/#deviceseturlblacklisturls

await device.setURLBlacklist(['.*firestore.googleapis.com.*']);

@tmatsuo
Copy link
Author

tmatsuo commented Jul 21, 2023

@asafkorem Thanks for the info! Testing it now.

Update: Yay, it work for us now! I had to run it after launching the app like this:

  beforeAll(async () => {
    await device.launchApp();
    await device.setURLBlacklist(['.*firestore.googleapis.com.*']);
  });

@tmatsuo tmatsuo closed this as completed Jul 21, 2023
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

3 participants