Can someone help me and tell me whether Detox test tool supports QR code scanning for mobile apps (Android & iOS)? I have seen in the Github page that there was some sort of bug raised and the question has been moved to stackoverflow and I couldn't find it here.
Asked
Active
Viewed 394 times
1 Answers
0
I don't know how your application would scan QR codes but here is how you can do to test it.
ScanQR.jsx
function ScanQR() {
const [data, setData] = useState(null);
function scan() {
// here is the logic to scan
setData(data);
}
...
}
Then you will create a mock file ScanQR.2e2.jsx
following this instructions
ScanQR.2e2.jsx
function ScanQR() {
const [data, setData] = useState(null);
function scan() {
// replace the logic to scan with actual data results
const data = 'some data here';
setData(data);
}
...
}
This way whenever you test you app the mock file will replace the actual file in which you really scan QR codes using camera.

Safiy Zaghbane
- 38
- 7
-
Thanks Safiy! So if I get this right, it basically kinda 'mocks' the QR code scanning. I mean it is not going to scan the QR code image as such; it just recognizes a pre-loaded QR image and reads the stand-in data. Not that I am complaining, I just want to make sure I got the idea/strategy right. (Needless to say - I am new to Detox! ) – Mishal Alexander Apr 15 '20 at 12:31
-
@MishalAlexander Yes, thats exactly the strategy ! – Safiy Zaghbane Apr 16 '20 at 07:56