How to check screenshots in React Native?

I would like to test the React Native app with screenshots. The javascript UIAutomation file will be executed by fastlane and should provide me with all the objects I need to view. This part works great.

My main problem is that I don’t understand how I can click an element. Each example I found was simple objective-c and used standard navigation elements like a tab bar. My app has a Burger icon that has a click on event TouchableHighlightthat opens a menu. I am looking for the opportunity to refer to one element TouchableHighlightin order to interact with it.

Bonus points for answers that don’t have me write Objective-C.

+4
source share
3 answers

Fastlane (a more specific snapshot) has legacy user interface automation for user interfaces. If you need to upgrade gems, your Javascript will not work for user interface tests (which are written in Obj C or Swift)

Why change user interface tests?

Swift Objective C .

https://github.com/fastlane/snapshot

, - , React Native, UI: https://github.com/fastlane/snapshot/issues/267

+4

fastlane, Jest, . , , , , , , , ( iOS)

+3

.

$ react-native -v
react-native-cli: 2.0.1

$ react-native init NativeSnapshots

$ cd NativeSnapshots

$ react-native run-ios

, .

$ cd ios

$ fastlane snapshot init

Fastlane:

[14:37:56]: For more information, check out https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
✅  Successfully created SnapshotHelper.swift './SnapshotHelper.swift'
✅  Successfully created new Snapfile at './Snapfile'
-------------------------------------------------------
Open your Xcode project and make sure to do the following:
1) Add a new UI Test target to your project
2) Add the ./fastlane/SnapshotHelper.swift to your UI Test target
   You can move the file anywhere you want
3) Call `setupSnapshot(app)` when launching your app

  let app = XCUIApplication()
  setupSnapshot(app)
  app.launch()

4) Add `snapshot("0Launch")` to wherever you want to create the screenshots

More information on GitHub: https://github.com/fastlane/fastlane/tree/master/snapshot

1:

Xcode Version 8.3.3 > NativeSnapshots.xcodeproj

File > New > Target > iOS UI Testing Bundle

ui target

2: . /fastlane/SnapshotHelper.swift

Highlight NativeSnapshotsUITests
File > Add Files to NativeSnapshots
Select ./fastlane/SnapshotHelper.swift, Enter

3: setupSnapshot ()

NativeSnapshotsUITests/NativeSnapshotsUITests.swift Xcode.

:

    XCUIApplication().launch()

    let app = XCUIApplication()
    setupSnapshot(app)
    app.launch()

4: snapshot("0Launch") ,

testExample() .

func testExample() {
    snapshot("0Launch")
}

Edit the Snapfile to avoid the huge matrix.

devices([
  "iPhone 6"
])

languages([
  "en-US"
])

scheme "NativeSnapshots"

He must be ready for work.

$ cd ios && fastlane snapshot

Copied from aj0strow

0
source

Source: https://habr.com/ru/post/1612788/


All Articles