Follow the setup guide on fastlanes website
- Open xCode -> Product -> Scheme -> Edit Sceme
- (optional) In all windows, select (Release) as build configuration (not needed, but helps you avoid yellow box warnings during screenshots)
- Make sure Executable is set to your app
- Under "Build" - De-select "parallelize build"
- Under "Build" - Make sure "Test" and "Run" is selected for the test target.
- Close the Schema Window
- Select your root project -> Select your UI Test Target -> Build Phases -> expand "Target dependencies"
- Add "React" as a target dependency.
Setup your screenshot procedure (see below) - and run fastlane snapshot
.
If you have not already done so, move your Fastlane files into /fastlane
folder, fastlane will automatically look for supported files here, and helps you keep your project organized.
Give the elements you want to tap a testID="<yourID>"
Ex.
<TouchableOpacity testID="BTN2" onPress={() => {}}>
<Text>Touch me</Text>
</TouchableOpacity>
(HARD) In your testfile, where you normally record - You can try the recorder, but be very carefull of the points your touching - Its very picky that way.
(EASIER) I think its easier to be explicit about it - TouchableOpacity seems to allways show up in "otherElements" no matter how deep its nested:
// Helps us not to continue before react has compiled its stuff and actually loaded the application
XCUIApplication().otherElements["BTN2"].waitForExistence(timeout: 30)
//Take the screenshot and give it a name of "01Launch"
snapshot("01Launch")
// Tap the element with testID="BTN2"
XCUIApplication().otherElements["BTN2"].tap()
snapshot("02BTN2State")
// Wait 1 second before continuing
sleep(1)
XCUIApplication().otherElements["BTN1"].tap()
snapshot("03BTN1State")
Dynamic content? Set your testID=´MyContent_${index}´
- Fastlane complains about not installed languages and defaults to system default.
- Simulator gets erased everytime, makes it hard to use asyncStorage and setting up testdata. (even if
erase_simluator = false
)
If you find anything worthy of a mention, submit a PR or create an issue.