Set up permissions for e2e test with Detox

Hello, i’m having essentially the same problem as described in "Experience needs permissions" popup using detox.
I’m using Detox for e2e testing, and my app asking for permissions, specifically for location permission on main screen. So my testing code looks like this:

import { reloadApp } from 'detox-expo-helpers'
beforeAll(async () => {
    await reloadApp({
      permissions: { location: 'inuse', notifications: 'YES' },
    })
}

But when test is running, application shows system alert that says “Experience needs permissions. You’ve already granted permission to another Expo experience. Allow @username/appname to use it also?”. I wasn’t able to find how to dismiss this alert from inside Detox. Basically their doc says that you should launch an app with permissions already enabled.
It seems that client application recognized that permissions are enabled but doesn’t understand for what experience specifically.
So my question is: how do I launch an app from Detox test using detox-expo-helpers with specified permission for a particular experience?
I’m using:

expo: 32.0.0
detox: 10.0.5
detox-expo-helpers: 0.6.0
mobile client version: 2.10.0.105125

@runandrew were you able to solve this?

@syndicate Unfortunately I was not able to resolve it. A few others were having the same problem as well.

1 Like

@quinlanj I see you contributed to detox-expo-helpers, I would greatly appreciate if you can point me where to look.

hi @syndicate , so our permissions module looks to see if the particular experience was granted the permission. it looks like detox exposes a way to set global permission, so from the point of view of the expo client app, ‘some other experience’ has gotten permission, but your current experience (app) has not.

while this is expected behavior for our app, i understand that it is not ideal for testing. i’ve made a gh issue and assigned it to myself. will work on it when i am next able to! https://github.com/expo/expo/issues/3516

1 Like

Thanks a lot! Will be looking forward to it!