I'm trying to write an e2e test using Detox for a flow where a user shares a deeplink to a certain screen in the app. I want to be able to capture the share link generated when a user clicks the 'share' button (which on a real device would open the native share popup), then navigate to that link using device.openUrl(). It should look something like this:
await element(by.id('test-id-of-share-button')).tap();
const sharedUrl = obtainTheUrlPassedToTheSharePopupBySomeMagicalVoodooWay();
await device.openURL({ url: sharedUrl });
await expect(element(by.id('test-id-of-element-on-target-screen'))).toBeVisible();
Thing is, I don't know how to do this nicely. I can probably Mock the Share module, but then I'll somehow have to pass the data from the mock function to the test process. I can probably do this by running a simple http server in the test and calling that server from the mock function, but I think that there's got to be a better way to do that.
Would appreciate any insight.