Skip to content

Instantly share code, notes, and snippets.

/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React, {useState} from 'react';
import {Button, Modal, SafeAreaView, Text, View} from 'react-native';

Test Your Library against React Native 0.74.0-rcs.

We cut the branch for 0.74 and we released the first RCs. We would like to check that the libraries in the ecosystem are working well, especially with the New Architecture.

To simplify the work, we prepared a sort of template you can use to test your library against the most recent version of React Native. There are two ways to test this:

  1. Using a newly created app;
  2. Using the example app that might live in your library repo.

The first approach can be used to check whether the latest version you already released is compatible with the New Architecture.

@cipolleschi
cipolleschi / App.tsx
Created January 31, 2024 15:34
Sample app to test TextInput
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import {
SafeAreaView,
import UIKit
import PlaygroundSupport
class MyViewControllerA : UIViewController {
let viewControllerB = MyViewControllerB()
override func loadView() {
print("MyViewControllerA - loadView Invoked")
let view = MyViewA()
view.push = { [unowned self] in
protocol Product {
var price: Decimal { get }
var releaseDate: Date { get }
}
protocol Discountable {
var discount: Double { get }
}
func testPurchasingCoins_success() {
self.app.launchArguments.append(contentsOf: ["-mockPurchase", "true"])
self.app.launch()
let homeView = self.app.otherElements[HomeView.AccessibilityIdentifiers.homeView.rawValue]
XCTAssertTrue(homeView.exists)
self.app.buttons[HomeView.AccessibilityIdentifiers.purchase.rawValue].tap()
XCTAssertEqual(self.app.staticTexts[HomeView.AccessibilityIdentifiers.coins.rawValue].label, "1000")
}
func buildDependencies() -> Dependencies {
#if UITESTING
if UserDefaults.standard.object(forKey: "mockPurchase") != nil {
let mockedMonetizationResult = UserDefaults.standard.bool(forKey: "mockPurchase")
return Dependencies(purchaseManagerDependencies: .mocked(with: mockedMonetizationResult))
}
#endif
return Dependencies()
}
func testPurchasingCoins_success() {
self.app.launchArguments.append(contentsOf: [
"-mockPurchase", "true"
])
self.app.launch()
// ... assert what should happen ...
}
func testPurchasingCoins_failure() {
self.app.launchArguments.append(contentsOf: [
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let scene = (scene as? UIWindowScene) else { return }
override func setUpWithError() throws {
try super.setUpWithError()
continueAfterFailure = false
self.app = XCUIApplication()
let path = Bundle.allBundles.compactMap { $0.path(forResource: "state", ofType: "json") }.first!
self.app.launchArguments = [
"-initialScreen", "home_screen",
"-state", path,
"-reset", "true"
]