Skip to content

Commit 2d9107b

Browse files
Merge pull request #324 from reown-com/chore/bump-rn-version
chore: updated rn version & deps
2 parents b7301b5 + 0536418 commit 2d9107b

23 files changed

+2928
-1932
lines changed

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 18.20.0

TESTING.md

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
# Testing Setup
2+
3+
This document describes the testing setup for the WalletConnect AppKit React Native project.
4+
5+
## Shared Jest Setup
6+
7+
To avoid duplication and ensure consistency across packages, we use a shared Jest setup approach:
8+
9+
### Structure
10+
11+
- `jest-shared-setup.ts`: Contains common mocks used across all packages
12+
- Package-specific `jest-setup.ts` files: Import the shared setup and add package-specific mocks
13+
14+
### How it works
15+
16+
1. The root `jest.config.ts` defines a moduleNameMapper that maps `@shared-jest-setup` to the shared setup file:
17+
18+
```js
19+
moduleNameMapper: {
20+
'^@shared-jest-setup$': '<rootDir>/jest-shared-setup.ts'
21+
}
22+
```
23+
24+
2. Each package's `jest.config.ts` overrides this mapping to use a relative path:
25+
26+
```js
27+
moduleNameMapper: {
28+
'^@shared-jest-setup$': '../../jest-shared-setup.ts'
29+
}
30+
```
31+
32+
3. Each package has its own `jest-setup.ts` file that imports the shared setup and only adds package-specific mocks:
33+
34+
```js
35+
// Import shared setup
36+
import '@shared-jest-setup';
37+
38+
// Import helper functions from shared setup (if needed)
39+
import { mockThemeContext, mockUseTheme } from '@shared-jest-setup';
40+
41+
// Apply package-specific mocks
42+
mockThemeContext('../src/context/ThemeContext');
43+
mockUseTheme('../src/hooks/useTheme');
44+
45+
// Add any other package-specific mocks here if needed
46+
```
47+
48+
### Shared Mocks
49+
50+
The shared setup includes mocks for:
51+
52+
- `@react-native-async-storage/async-storage`
53+
- React Native components and APIs (StyleSheet, Dimensions, Platform, etc.)
54+
- `react-native-svg` components
55+
- Helper functions for mocking package-specific modules
56+
57+
All common mocks are centralized in the shared setup file, eliminating duplication across packages. This makes the testing setup more maintainable and consistent.
58+
59+
### Adding New Mocks
60+
61+
To add a new mock that should be shared across packages:
62+
63+
1. Add it to `jest-shared-setup.ts`
64+
2. If it's a function that needs to be imported by packages, export it from `jest-shared-setup.ts`
65+
66+
For package-specific mocks, add them to the package's `jest-setup.ts` file.
67+
68+
### Type Declarations
69+
70+
Each package includes a type declaration file for the shared setup module:
71+
72+
```ts
73+
// types/shared-jest-setup.d.ts
74+
declare module '@shared-jest-setup' {
75+
export function mockThemeContext(modulePath: string): void;
76+
export function mockUseTheme(modulePath: string): void;
77+
}
78+
```
79+
80+
## Running Tests
81+
82+
To run tests for all packages:
83+
84+
```bash
85+
yarn test
86+
```
87+
88+
To run tests for a specific package:
89+
90+
```bash
91+
yarn workspace @reown/appkit-[package-name]-react-native test
92+
```
93+
94+
## Playwright Testing
95+
96+
For end-to-end testing of web interfaces (such as the web demo or web views within the React Native app), we use Playwright.
97+
98+
### Setup
99+
100+
1. Install Playwright:
101+
102+
```bash
103+
# Install Playwright and browsers
104+
npx playwright install
105+
```
106+
107+
2. Playwright tests are located in the `e2e` directory at the root of the project.
108+
109+
### Writing Tests
110+
111+
Playwright tests are written using the Playwright Test framework. Here's a basic example:
112+
113+
```typescript
114+
// e2e/example.spec.ts
115+
import { test, expect } from '@playwright/test';
116+
117+
test('basic test', async ({ page }) => {
118+
// Navigate to the page
119+
await page.goto('https://your-app-url.com');
120+
121+
// Interact with the page
122+
await page.click('text=Sign In');
123+
await page.fill('input[name="email"]', 'user@example.com');
124+
await page.fill('input[name="password"]', 'password');
125+
await page.click('button[type="submit"]');
126+
127+
// Assert the result
128+
await expect(page.locator('.welcome-message')).toContainText('Welcome');
129+
});
130+
```
131+
132+
### Running Playwright Tests
133+
134+
To run all Playwright tests:
135+
136+
```bash
137+
npx playwright test
138+
```
139+
140+
To run a specific test file:
141+
142+
```bash
143+
npx playwright test e2e/example.spec.ts
144+
```
145+
146+
To run tests in headed mode (with browser visible):
147+
148+
```bash
149+
npx playwright test --headed
150+
```
151+
152+
To run tests in a specific browser:
153+
154+
```bash
155+
npx playwright test --browser=chromium
156+
# or
157+
npx playwright test --browser=firefox
158+
# or
159+
npx playwright test --browser=webkit
160+
```
161+
162+
### Debugging Playwright Tests
163+
164+
To debug tests:
165+
166+
1. Run with the `--debug` flag:
167+
168+
```bash
169+
npx playwright test --debug
170+
```
171+
172+
2. Use the Playwright Inspector to step through the test.
173+
174+
3. Add `await page.pause()` in your test to pause at a specific point.
175+
176+
### Generating Test Reports
177+
178+
To generate an HTML report:
179+
180+
```bash
181+
npx playwright test --reporter=html
182+
```
183+
184+
Then open the report:
185+
186+
```bash
187+
npx playwright show-report
188+
```
189+
190+
### Testing Mobile Web Views
191+
192+
For testing mobile web views:
193+
194+
```typescript
195+
test('mobile view test', async ({ browser }) => {
196+
// Create a new context with mobile device emulation
197+
const context = await browser.newContext({
198+
viewport: { width: 375, height: 667 },
199+
userAgent:
200+
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
201+
});
202+
203+
const page = await context.newPage();
204+
// Continue with your test...
205+
});
206+
```
207+
208+
### CI Integration
209+
210+
Playwright tests can be integrated into your CI pipeline. Here's an example GitHub Actions workflow:
211+
212+
```yaml
213+
name: Playwright Tests
214+
on:
215+
push:
216+
branches: [main, master]
217+
pull_request:
218+
branches: [main, master]
219+
jobs:
220+
test:
221+
timeout-minutes: 60
222+
runs-on: ubuntu-latest
223+
steps:
224+
- uses: actions/checkout@v3
225+
- uses: actions/setup-node@v3
226+
with:
227+
node-version: 16
228+
- name: Install dependencies
229+
run: yarn install
230+
- name: Install Playwright Browsers
231+
run: npx playwright install --with-deps
232+
- name: Run Playwright tests
233+
run: npx playwright test
234+
- uses: actions/upload-artifact@v3
235+
if: always()
236+
with:
237+
name: playwright-report
238+
path: playwright-report/
239+
retention-days: 30
240+
```
241+
242+
For more information, refer to the [Playwright documentation](https://playwright.dev/docs/intro).

apps/native/app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"orientation": "default",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "automatic",
9+
"newArchEnabled": true,
910
"splash": {
1011
"image": "./assets/splash.png",
1112
"resizeMode": "contain",

apps/native/package.json

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,39 @@
1919
"build:web": "expo export -p web"
2020
},
2121
"dependencies": {
22-
"@expo/metro-runtime": "~3.2.3",
23-
"@react-native-async-storage/async-storage": "1.23.1",
24-
"@react-native-community/netinfo": "11.3.1",
22+
"@expo/metro-runtime": "~4.0.1",
23+
"@react-native-async-storage/async-storage": "2.1.2",
24+
"@react-native-community/netinfo": "11.4.1",
2525
"@reown/appkit-auth-wagmi-react-native": "1.2.2",
2626
"@reown/appkit-wagmi-react-native": "1.2.2",
2727
"@tanstack/query-async-storage-persister": "^5.40.0",
2828
"@tanstack/react-query": "5.56.2",
2929
"@tanstack/react-query-persist-client": "5.56.2",
30-
"@walletconnect/react-native-compat": "2.17.1",
31-
"expo": "~51.0.24",
32-
"expo-application": "~5.9.1",
33-
"expo-clipboard": "~6.0.3",
34-
"expo-status-bar": "~1.12.1",
35-
"expo-updates": "~0.25.21",
36-
"react": "18.2.0",
37-
"react-dom": "18.2.0",
38-
"react-native": "0.74.3",
30+
"@walletconnect/react-native-compat": "2.19.1",
31+
"expo": "^52.0.38",
32+
"expo-application": "~6.0.2",
33+
"expo-clipboard": "~7.0.1",
34+
"expo-status-bar": "~2.0.1",
35+
"expo-updates": "~0.27.3",
36+
"react": "18.3.1",
37+
"react-dom": "18.3.1",
38+
"react-native": "0.76.7",
3939
"react-native-get-random-values": "~1.11.0",
40-
"react-native-modal": "13.0.1",
41-
"react-native-svg": "15.2.0",
40+
"react-native-modal": "14.0.0-rc.0",
41+
"react-native-svg": "15.8.0",
4242
"react-native-toast-message": "2.2.1",
43-
"react-native-web": "~0.19.10",
44-
"react-native-webview": "13.8.6",
45-
"uuid": "3.4.0",
46-
"viem": "2.21.48",
47-
"wagmi": "2.12.33"
43+
"react-native-web": "~0.19.13",
44+
"react-native-webview": "13.12.5",
45+
"uuid": "^11.1.0",
46+
"viem": "2.23.10",
47+
"wagmi": "2.14.13"
4848
},
4949
"devDependencies": {
5050
"@babel/core": "^7.24.0",
5151
"@playwright/test": "^1.49.1",
5252
"@types/gh-pages": "^6",
5353
"@types/node": "^22.10.1",
5454
"@types/react": "~18.2.79",
55-
"@types/react-native": "0.72.2",
5655
"babel-plugin-module-resolver": "^5.0.0",
5756
"gh-pages": "^6.2.0",
5857
"typescript": "~5.3.3"

babel.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset']
2+
presets: ['module:metro-react-native-babel-preset'],
3+
plugins: [
4+
'@babel/plugin-transform-flow-strip-types',
5+
['@babel/plugin-proposal-class-properties', { loose: true }],
6+
['@babel/plugin-proposal-private-methods', { loose: true }]
7+
]
38
};

jest-setup.ts

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

0 commit comments

Comments
 (0)