I want to know if there is a way to test TouchID, currently i'm using Detox as e2e framwork, and i have touchID logic in my app. It would be nice simulate success and failure and interactions with system alerts binding to the process.
Hello,
Starting with version 0.6.0, AppleSimulatorUtils fully supports the simulator biometric system. You can enable or disable enrollment, as well as approve or fail authentication attempts using face or finger.
Now the matter of implementing it in Detox. While not a hard task at all, it will take time, and we are currently busy with other tasks. If you would like to contribute a PR implementing this functionality, we will be very happy to assist.
In the mean time, as a workaround, you can call applesimutils directly with the appropriate commands. Search the issues (open and closed) for examples of how to do that. You will need to obtain the current simulator ID from Detox, which is also possible.
Thank @LeoNatan appreciate it. I don't have much time free in the future, but maybe i can work on an PR for this. Thanks for the help
Thank you
Claiming this - will start work on it now.
@abunsen Fantastic, thank you!
I've reopened the issue, and we can discuss here if you need help.
So I believe all that needs to be done is a few functions need to be added to detox/src/devices/ios/AppleSimUtils.js, this is what I was thinking:
async matchBiometric(udid, matchType) {
if (!['face', 'finger'].include(matchType)) {
return;
}
const statusLogs = {
trying: `Trying to match ${matchType}...`,
successful: `Matched ${matchType}!`
};
await this._execAppleSimUtils({ args: `--byId ${udid} --${matchType}}` }, statusLogs, 1);
}
async unmatchBiometric(udid, matchType) {
if (!['Face', 'Finger'].include(matchType)) {
return;
}
const statusLogs = {
trying: `Trying to match ${matchType}...`,
successful: `Matched ${matchType}!`
};
await this._execAppleSimUtils({ args: `--byId ${udid} --unmatch${matchType}}` }, statusLogs, 1);
}
async setBiometricEnrollment(udid, toggle) {
let yesOrNo = toggle ? 'YES' : 'NO'
const statusLogs = {
trying: `Turning ${toggle ? 'on' : 'off'} biometric enrollment`,
successful: toggle ? 'Activated!' : 'Deactivated!'
};
await this._execAppleSimUtils({ args: `--byId ${udid} --biometricEnrollment ${yesOrNo}` }, statusLogs, 1);
}
Then tests need to be added in detox/src/devices/Device.test.js. Does that sound about right @LeoNatan?
This is now supported on iOS only, here are the docs: https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#devicesetbiometricenrollmentbool-ios-only
Most helpful comment
This is now supported on iOS only, here are the docs: https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#devicesetbiometricenrollmentbool-ios-only