Skip to content

Commit 80fa209

Browse files
Migrate React Native Jest setup to Expo
Assisted-By: devx/2d0344dc-43dd-4535-baf2-409ff9e93de5
1 parent 3b9fe99 commit 80fa209

51 files changed

Lines changed: 1416 additions & 5639 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ up:
2727
name: Run Checkout Kit workspace setup
2828
met?: ./scripts/setup_dev_workspace --check --skip-optional-prompts
2929
meet: ./scripts/setup_dev_workspace --skip-optional-prompts
30+
- custom:
31+
name: Prebuild React Native sample native projects
32+
met?: "false"
33+
meet: cd platforms/react-native && pnpm run prebuild -- all -- --clean
3034

3135
open:
3236
"GitHub": "https://github.com/Shopify/checkout-kit"
@@ -349,27 +353,21 @@ commands:
349353
long_desc: |
350354
Runs unit tests across all three React Native targets:
351355
- JS: Jest tests in `platforms/react-native/modules/@shopify/checkout-kit-react-native/tests/`
352-
- iOS: Swift Package protocol tests plus bridge tests in `platforms/react-native/modules/@shopify/checkout-kit-react-native/ios-tests/`
356+
- iOS: Swift Package tests at `platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/`
353357
- Android: Gradle JVM tests for `:shopify_checkout-kit-react-native`
354358
run: |
355359
set -e
356360
cd platforms/react-native && pnpm test
357361
cd modules/@shopify/checkout-kit-react-native/ios && swift test
358-
cd ../ios-tests && ./test
359362
cd ../../../..
360363
pnpm sample test:android -- --refresh-dependencies
361364
subcommands:
362365
js:
363366
desc: Run JS unit tests via jest
364367
run: cd platforms/react-native && pnpm test
365368
ios:
366-
desc: Run native iOS unit tests (Swift Package protocol tests + CocoaPods bridge fixture)
367-
run: |
368-
set -e
369-
cd platforms/react-native/modules/@shopify/checkout-kit-react-native/ios
370-
swift test
371-
cd ../ios-tests
372-
./test
369+
desc: Run native iOS unit tests via Swift Package
370+
run: cd platforms/react-native/modules/@shopify/checkout-kit-react-native/ios && swift test
373371
android:
374372
desc: Run native Android unit tests for the RN module
375373
run: |
@@ -437,10 +435,10 @@ commands:
437435
fi
438436
echo "Cleaned root, module and sample workspaces"
439437
440-
server:
438+
start:
441439
desc: Start Metro development server
442-
aliases: [s]
443-
run: cd platforms/react-native && pnpm sample start --reset-cache
440+
aliases: [s, server]
441+
run: cd platforms/react-native && pnpm sample start "$@"
444442

445443
ios:
446444
desc: Run the iOS sample app in the simulator.
@@ -468,17 +466,19 @@ commands:
468466
desc: Prebuild generated native sample projects.
469467
long_desc: |
470468
Runs Expo prebuild for the React Native sample and prepares platform-specific native dependencies.
469+
Existing native folders are preserved unless Expo's --clean arg is passed through.
471470
472-
dev rn prebuild Prebuild iOS and Android
473-
dev rn prebuild ios Prebuild iOS and install CocoaPods
474-
dev rn prebuild android Prebuild Android
475-
dev rn prebuild ios --local Prebuild iOS against in-repo Swift SDK sources
476-
dev rn prebuild android --local Prebuild Android against in-repo Android SDK artifacts
471+
dev rn prebuild Prebuild iOS and Android
472+
dev rn prebuild ios Prebuild iOS and install CocoaPods
473+
dev rn prebuild android Prebuild Android
474+
dev rn prebuild all -- --clean Regenerate iOS and Android native projects
475+
dev rn prebuild ios --local Prebuild iOS against in-repo Swift SDK sources
476+
dev rn prebuild android --local Prebuild Android against in-repo Android SDK artifacts
477477
478478
--local
479479
Use in-repo native SDKs where supported.
480480
syntax:
481-
optional: "[ios|android|all] [--local]"
481+
optional: "[ios|android|all] [--local] [-- <expo prebuild args>]"
482482
run: cd platforms/react-native && pnpm run prebuild -- "$@"
483483

484484
open:

platforms/react-native/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ Here's an example of how to get started with Apollo:
223223

224224
```tsx
225225
import {ApolloClient, gql, ApolloProvider} from '@apollo/client';
226-
import {API_VERSION, STOREFRONT_DOMAIN, STOREFRONT_ACCESS_TOKEN} from '@env';
226+
227+
const API_VERSION = '2026-04';
228+
const STOREFRONT_DOMAIN = 'your-store.myshopify.com';
229+
const STOREFRONT_ACCESS_TOKEN = 'your-public-storefront-access-token';
227230

228231
// Create a new instance of the ApolloClient
229232
const client = new ApolloClient({

platforms/react-native/__mocks__/react-native.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ module.exports = {
106106
requireNativeComponent,
107107
codegenNativeComponent,
108108
TurboModuleRegistry: {
109+
get: jest.fn((name: string) => {
110+
if (name === 'ShopifyCheckoutKit') {
111+
return ShopifyCheckoutKit;
112+
}
113+
return null;
114+
}),
109115
getEnforcing: jest.fn((name: string) => {
110116
if (name === 'ShopifyCheckoutKit') {
111117
return ShopifyCheckoutKit;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:@react-native/babel-preset'],
2+
presets: ['babel-preset-expo'],
33
};
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
module.exports = {
2-
preset: '@react-native/jest-preset',
2+
preset: 'jest-expo',
33
modulePathIgnorePatterns: ['modules/@shopify/checkout-kit-react-native/lib'],
44
modulePaths: ['<rootDir>/node_modules', '<rootDir>/sample/node_modules'],
55
moduleNameMapper: {
66
'^react$': '<rootDir>/node_modules/react',
7-
'^react-test-renderer$': '<rootDir>/node_modules/react-test-renderer',
87
'^react-native$': '<rootDir>/__mocks__/react-native.ts',
98
},
109
setupFiles: ['<rootDir>/jest.setup.ts'],
1110
transform: {
1211
'\\.[jt]sx?$': 'babel-jest',
1312
},
14-
globals: {
15-
'ts-jest': {
16-
tsConfig: {
17-
importHelpers: true,
18-
},
19-
},
20-
},
2113
};

platforms/react-native/jest.setup.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ declare global {
22
var __fbBatchedBridgeConfig: unknown;
33
}
44

5-
jest.mock('react-native');
6-
75
const platformConstants = {
86
forceTouchAvailable: false,
97
interfaceIdiom: 'phone',

platforms/react-native/modules/@shopify/checkout-kit-react-native/ios-tests/.xcode.env

Lines changed: 0 additions & 11 deletions
This file was deleted.

platforms/react-native/modules/@shopify/checkout-kit-react-native/ios-tests/AppDelegate.swift

Lines changed: 0 additions & 48 deletions
This file was deleted.

platforms/react-native/modules/@shopify/checkout-kit-react-native/ios-tests/CheckoutKitReactNativeDemo-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)