Testing App Launch Time for React Native Sample App – Expo

Create Sample App using Expo

When you create an app using Expo, there are no iOS and Android folder.

Create iOS and Android folder in Expo Sample Project

npx expo prebuild

Setup iOS App Launch Tests

Add UI Testing Bundle and write a test cases


@MainActor
    func testExample() throws {
        // UI tests must launch the application that they test.
        let app = XCUIApplication()
        app.launch()

        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

    @MainActor
    func testLaunchPerformance() throws {
        if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
            // This measures how long it takes to launch your application.
            let measureOptions = XCTMeasureOptions()
            measureOptions.iterationCount = 10
          measure(metrics: [XCTApplicationLaunchMetric()], options: measureOptions) {
                XCUIApplication().launch()
            }
        }
    }

Results

I ran 10 times and it’s average launch time is 0.157s (157ms).

Leave a comment

Quote of the week

"People ask me what I do in the winter when there's no baseball. I'll tell you what I do. I stare out the window and wait for spring."

~ Rogers Hornsby