Detox: Seems `device.setURLBlacklist` documented incorrectly

Created on 27 Dec 2019  路  7Comments  路  Source: wix/Detox

@simonracz @rotemmiz

According to the doc I assumed that the .setURLBlacklist should disable connections to the listed urls. However, in test I see that

  it('setURLBlacklist() should disable synchronization for given endpoint', async () => {
    const url = device.getPlatform() === 'ios' ? '.*localhost.*' : '.*10.0.2.2.*';
    await device.setURLBlacklist([url]);

    await element(by.id('LongNetworkRequest')).tap();
    await expect(element(by.text('Long Network Request Working!!!'))).toBeNotVisible();
    await waitFor(element(by.text('Long Network Request Working!!!'))).toBeVisible().withTimeout(4000);
    await expect(element(by.text('Long Network Request Working!!!'))).toBeVisible();

    await device.setURLBlacklist([]);
  });

that test supposed that after blacklisting url request still work.

Expected behaviour -

  it('setURLBlacklist() should disable synchronization for given endpoint', async () => {
    const url = device.getPlatform() === 'ios' ? '.*localhost.*' : '.*10.0.2.2.*';

    // check blocking url
    await device.setURLBlacklist([url]);
    await element(by.id('LongNetworkRequest')).tap();
    await expect(element(by.text('Long Network Request Working!!!'))).toBeNotVisible();
    await waitFor(element(by.text('Long Network Request Working!!!'))).toBeNotVisible().withTimeout(4000);
    await device.setURLBlacklist([]);

    // check reseting block
    await element(by.id('LongNetworkRequest')).tap();
    await expect(element(by.text('Long Network Request Working!!!'))).toBeNotVisible();
    await waitFor(element(by.text('Long Network Request Working!!!'))).toBeVisible().withTimeout(4000);
    await device.setURLBlacklist([]);
  });

am I wrong?

questiostack overflow ios

All 7 comments

As docs say, it only disables network sync to those endpoints, not the network calls themselves...

however according to my test - requests (with fetch) to that url (I use mask '*) also blocked

I started looking in cause I can't reset that blacklick.

Can you explain, what does sync in this case mean?

Please read the documentation. There is explanation how detox works and what synchronization means. Since you aren't familiar with the synchronization concepts, why are you even attempting to use this API?

We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the detox tag.

Feel free to post your Stack Overflow question here for more visibility. We'll take a look at it.

For issues with Expo apps, it is most likely not an issue with Detox itself, but with the Expo runtime or with incorrect Detox setup. For support on how to use Detox with Expo, you should contact the Expo team or the Expo community.

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

@LeoNatan I've read the docs. But
1) docs are not clear (naming is also confusing. Is there any reason why .setURLBlacklist not named with mentions of synchronization?)
2) it does not explain the behavior I see in my tests
3) test, I've mentioned above still not clear for me

I've looked in the "core principles" document, and indeed there is no mention of how we sync, which is peculiar, given how important this aspect is. I will add a few word on it now.

The API is called the way it is, because we reused the name from Earl Grey, which is a framework we use internally for synchronizing Detox and the app.

OK, I've updated the docs. Please read:

https://github.com/wix/Detox/blob/master/docs/More.DesignPrinciples.md
https://github.com/wix/Detox/blob/master/docs/Troubleshooting.Synchronization.md

These documents should explain how Detox works, and more specifically, how synchronization works and how to control it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carlosalmonte04 picture carlosalmonte04  路  4Comments

tomball123 picture tomball123  路  4Comments

LeoNatan picture LeoNatan  路  4Comments

rengarima picture rengarima  路  4Comments

danut-t picture danut-t  路  3Comments