-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implement facebook/idb tool (applesimeutils replacement) #1371
Comments
Hello, one of the authors of the More than happy to give pointers/advice if you need them. As far as the maturity of the project goes, we've been using this in production for nearly 2 years now and it's only just now that we've open sourced it. |
Hey @lawrencelomax !! Good to have you here, actually I do have a few questions:
|
I hear you on this as know that this has been a problem in the past. The biggest reason for this is that
Device App launching has some interesting constraints, including the app must be a dev build but we do support passing environment variables. This is because the only way of launching an application on a device is to treat it as a debug session, even if you're not interested in running debugger commands. I think one area that we would need to figure out is the You may want to check out how things such as Reveal do this as IIRC they use dylib injection in a similar way to how you'd be interested in doing it in Detox. |
Thanks for commenting. We have always known that signing will be a requirement for running on device. My idea has always been to deduce the signing identity from the user's project and then attempt to sign it with the Detox framework and touched entitlements. This is probably less suitable for device labs, where the signing certificate may not be present on the machine running the test, but since there is no escape from signing, I don't think there is any other way. What the Reveal guys are doing is to include an integration script that does the heavy lifting (similar to what we do in Detox Instruments). This still requires some changes to the user project. We may go down that road, but it is not planned yet (attaching Detox has repercussions, even if tests are not running). |
Hi! We are having trouble setting our app's location for testing with Detox, so I wanted to ask for help figuring it out.
The Thanks! |
Hello, Unfortunately, I didn't implement idb support in Detox. I did play a little with the tool and was met with some issues. It felt to me that the tool is not ready yet. That was a while back, but I have not had time to further investigate. PRs are welcome. I'd say "as a workaround, use fbsimctl for now", but idb seems to be incompatible with fbsimctl... 😂 |
@LeoNatan how would you recommend running the idb command inside the test? Making a script that runs along with I've tried running |
Detox tests run in node, so you can use standard node facilities to call idb manually. Regarding device identifier, could be that the entire simulator runtime uses the same coordinates, so a specific device needs not be provided. That makes your life even easier, because you don't need to find the device identifier from the Detox internals. So just call the |
in case anyone was wondering how to do it, after installing idb replaced my device.setLocation call with: exec("idb list-targets | grep -n 'Booted'", (err, stdout, stderr) => {
console.log("idb list-targets - ", err, stdout, stderr);
const tempDevice = stdout.split("|")[1].trim();
exec(
"idb set-location --udid " + tempDevice + " 32.0853 34.7818",
(err, stdout, stderr) => {
console.log("setLocation - ", err, stdout, stderr);
}
);
}); |
Please note that you should not assume only one |
How would one go about using the internals? |
I've tried @OisinOKeeffe approach and whenever I run a test, it spends a lot of time to even start the first test, and then when it finishes, every test has failed even though I saw it pass. I have a coulple of errors in my console: First, it says that signal 4 was flaged
It also fails every test with a timeout (which I believe is the time it takes to even start the test suite):
Also, some of the tests say that the app crashed because The logs that @OisinOKeeffe puts in the code bring me this:
Despite all this, I can see location has changed to the one I selected ¯_(ツ)_/¯ |
You can obtain the device id using The crash doesn’t seem related to me. |
I was able to fix it by writing it this way:
@OisinOKeeffe how do you run the |
Instead of using the booted device, try the following line:
|
Very cool, based off of @LeoNatan's response I think I am going to do the following to make sure I am targeting the right device.
@ayelenmarie when I ran my test all I had to do was ensure that the aforementioned was run in place of device.setLocation and my simulator location was updated without having to do anything else. Why would I need to run idb companion? |
@OisinOKeeffe mine does not work unless I don't have that simulator's companion running. Which version of |
@ayelenmarie I wasn't following until today when I attempted to execute the idb command again and got some message about not being able to connect to the bridge. After some troubleshooting a restart seems to have cleared up my issue and I am able to execute the command again without any issue. Try |
It works now! Thanks @OisinOKeeffe for your insight. Restarting it worked for me as well as the @LeoNatan aside from |
I don't think so. |
its not details on the simulator but you can access details of the detox config that is being run like so (here I am accessing the type ) device._deviceConfig.type |
Hi, hopping on the conversation since the problems I just started having led me here.
To my knowledge so far, I'm running into errors due to fbsimctl not being compatible or updated in a long time. (I'm testing against iPhone X, iOS 13.0)
(Thanks @ayelenmarie and @OisinOKeeffe )
Does that sound about right? |
I tried idb and lyft/set-simulator-location, none of them work when the ios simulator is running headless (like on CircleCI) =( |
Yeah, it seems idb is a broken mess. I'm wondering whether I should downgrade Detox at this point, not sure whether it would help. |
It might be a limitation of the simulator runtime. |
For people coming here, here is how to install
|
And don't forget to import
|
@ayelenmarie @LeoNatan Thanks for your input on this issue, it has been quite helpful. I've been rummaging for days on how to first get fbsimctl to work and finally hit upon your thread and accordingly dumped it for idb. I had issues with finding idb on the system and had to hardcode the absolute path to the binary, otherwise it was failing silently and the stdout you had doesn't really show me the error... The way I got it running was as follows:
|
had the same issue with idb, I had to use something like |
@d4vidi, sounds like it is high time to start moving towards |
It sounds like an interesting thing to do but I'm not sure why now is the right time, tbh |
fbsimctl is used only for location changing. It can also probably be implemented as part of AppleSimUtils. |
@d4vidi, it is already deleted from the @LeoNatan, that's an option as well. I just wonder if |
@noomorph Last I tried, idb was buggy. Those bugs are still open: The reason we moved away from fbsimctl and just used |
I would suggest making this apparent in the README if there's no effort going to be put into rectifying it. A simple link to the issue would do, because from a user's perspective and mostly new ones, idb supposed to be the better solution but it is not and having to debug something like this is very time-consuming. That time could be saved. |
I have attempted to use the The problem I'm encountering is that the command appears to execute successfully when the tests run, but the iOS simulator is not able to retrieve the current location. import { exec } from 'child_process';
import { device } from 'detox';
const execPromise = (command: string) => {
return new Promise((resolve, reject) => {
exec(command, (err, stdout, stderr) => {
if (err) {
reject(err);
} else if (stderr) {
reject(new Error(stderr));
} else {
resolve(stdout);
}
});
});
};
const setDeviceLocation = (lat: number, long: number) => {
if (device.getPlatform() === 'android') {
return device.setLocation(lat, long);
} else {
return execPromise(`applesimutils --byId ${device.id} --setLocation "[${lat}, ${long}]"`);
}
} However, if I run the command directly in my terminal, the simulator is able to retrieve the current location. I do not see any errors thrown from the
|
Thanks @zacharyweidenbach! We will revisit |
@zacharyweidenbach Did you manage to get this working? I am also experiencing the same issue. |
Unfortunately no. For now, we've accepted that we cannot get e2e test coverage on features that require control over the device's location on iOS. Back when I was troubleshooting this, it appeared to be a bug with |
This worked for me const { exec } = require('child_process');
const setLocation = async () => {
log.info('setLocation **');
if (device.getPlatform() === 'ios') {
exec(
"idb list-targets | grep -n 'Booted'",
(err: any, stdout: any, stderr: any) => {
log.info('idb list-targets - ', err, stdout, stderr);
log.info(
'Execute Command to set Location for iOS **',
'idb set-location --udid ' + device.id + ' 25.2769 55.2962',
);
exec(
'idb set-location --udid ' + device.id + ' 25.2769 55.2962',
(err: any, stdout: any, stderr: any) => {
log.info('setLocation - ', err, stdout, stderr);
},
);
},
);
} else {
await device.setLocation(25.2769, 55.2962);
}
}; |
Let's move further location-related discussions to #3240 🙏🏻 |
Talking with LeoNatan in #629 I mentioned Facebook released a new tool that replaces\includes
fbsimctl
that is calledidb
. They will start monitoring and updating that repo instead of the other one and they are suggesting everyone to move to this new tool instead. So it will be great if Detox could migrate as well!Currently it's under construction but as it supposedly fixes some issues that
fbsimctl
has, I might as well suggest it here.Here is the repo for
idb
: https://github.com/facebook/idbNote: This tool is only for iOS, I assume it's the equivalent of
adb
for Android?Thanks!
The text was updated successfully, but these errors were encountered: