Add the appropriate “Tag” based on what Expo library you have a question on.
Hello everyone, can any experienced expo developers share with me what is the best practices on how to test the function invoked from onBarCodeScanned in BarCodeScanner component? Appreciate any insights!
Do you mean to test the function in a project? For that, you can check the callback’s usage in the example from Expo documentation here: BarCodeScanner - Expo Documentation.
Below is an example code. I want to test handleBarCodeScanned function.
There are 2 approaches I thought of -
Blackbox testing
Whitebox testing
For (1), I will need testing-library/react-native, but how do I trigger that particular event if there is no QR code available?
For (2), I can’t find any way to invoke the handleBarCodeScanned function and also how to structure it for whitebox testing more specifically for this example despite searching online.