wix / Detox

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

Random `session.sessionId` is not enough random #3768

Open noomorph opened 1 year ago

noomorph commented 1 year ago

What happened?

This report comes from the engine team at Wix. They have a very specific use case – they use explicit bundle IDs for installing, launching, terminating, and uninstalling apps like this:

await device.launchApp('com.wix.appId');
await device.terminateApp('com.wix.appId');

This bug arose on the boundary of two adjacent test suites:

The previous suite did not terminate the app – and by the way, technically, you are not obliged to. The next suite launched another app with the same -sessionId <UUID> parameter as the previous launch.

That created a situation when:

DetoxInternalError: cannot disconnect an unknown connection from the session 97aac38f-32cb-386b-ea2c-b93f07e87a20

What was the expected behaviour?

The apps should have been using different sessionIds.

Was it tested on latest Detox?

Help us reproduce this issue!

No response

In what environment did this happen?

Detox version: 20.1.0 Node version: 14.x Test-runner (select one): jest

Detox logs

No response

Device logs

No response

More data, please!

No response

d4vidi commented 1 year ago

@noomorph Are you sure that this is the right approach? Technically, we don't support multiple apps yet, and all the more so - device.selectApp() starts by terminating the currently selected one. I understand that this would not imply supporting multiple apps per se, but I'm a bit concerned that without hard-terminating all left-over apps in the beginning of each test (i.e. the alternative approach) there would in fact remain other numerous edge-cases that we don't know how to handle, besides the the session ID.

noomorph commented 1 year ago

@d4vidi, well, it is part of a code that will be refactored heavily sooner or later. We could live with it as fine as without it.