Skip to content

Commit e0b9fdc

Browse files
committed
fix: Patch react-native jest to work correctly
1 parent dd4531e commit e0b9fdc

File tree

5 files changed

+70
-7
lines changed

5 files changed

+70
-7
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/jest/mockComponent.js b/jest/mockComponent.js
2+
index 6ff4f6bd3e248ca8b04d605150dc68df21e72220..cf56328b3519f9283ce3bae4b5af779425ee4cc9 100644
3+
--- a/jest/mockComponent.js
4+
+++ b/jest/mockComponent.js
5+
@@ -39,7 +39,7 @@ export default function mockComponent<
6+
React.ElementProps<typeof RealComponent>,
7+
> =
8+
typeof RealComponent === 'function' &&
9+
- RealComponent.prototype.constructor instanceof React.Component
10+
+ RealComponent.prototype && RealComponent.prototype.constructor instanceof React.Component
11+
? RealComponent
12+
: React.Component;
13+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"prettier": "3.6.2",
9797
"react": "19.1.0",
9898
"react-dom": "19.1.0",
99-
"react-native": "0.81.0",
99+
"react-native": "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch",
100100
"react-native-safe-area-context": "^5.0.0",
101101
"react-native-screens": "^4.1.0",
102102
"react-test-renderer": "^19.0.0",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"qs": "^6.13.1",
208208
"react": "19.1.0",
209209
"react-dom": "^19.0.0",
210-
"react-native": "0.81.0",
210+
"react-native": "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch",
211211
"react-native-safe-area-context": "^5.0.0",
212212
"react-native-screens": "^4.1.0",
213213
"react-test-renderer": "^19.0.0",

packages/test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
"jest": "^30.0.0",
166166
"react": "19.1.0",
167167
"react-dom": "19.1.0",
168-
"react-native": "*",
168+
"react-native": "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch",
169169
"react-test-renderer": "*",
170170
"rollup-plugins": "workspace:*"
171171
}

yarn.lock

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,7 @@ __metadata:
32263226
qs: "npm:^6.13.1"
32273227
react: "npm:19.1.0"
32283228
react-dom: "npm:^19.0.0"
3229-
react-native: "npm:0.81.0"
3229+
react-native: "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch"
32303230
react-native-safe-area-context: "npm:^5.0.0"
32313231
react-native-screens: "npm:^4.1.0"
32323232
react-test-renderer: "npm:^19.0.0"
@@ -3278,7 +3278,7 @@ __metadata:
32783278
jest: "npm:^30.0.0"
32793279
react: "npm:19.1.0"
32803280
react-dom: "npm:19.1.0"
3281-
react-native: "npm:*"
3281+
react-native: "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch"
32823282
react-test-renderer: "npm:*"
32833283
rollup-plugins: "workspace:*"
32843284
peerDependencies:
@@ -25848,7 +25848,7 @@ __metadata:
2584825848
languageName: node
2584925849
linkType: hard
2585025850

25851-
"react-native@npm:*, react-native@npm:0.81.0":
25851+
"react-native@npm:0.81.0":
2585225852
version: 0.81.0
2585325853
resolution: "react-native@npm:0.81.0"
2585425854
dependencies:
@@ -25898,6 +25898,56 @@ __metadata:
2589825898
languageName: node
2589925899
linkType: hard
2590025900

25901+
"react-native@patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch":
25902+
version: 0.81.0
25903+
resolution: "react-native@patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch::version=0.81.0&hash=9d0b26"
25904+
dependencies:
25905+
"@jest/create-cache-key-function": "npm:^29.7.0"
25906+
"@react-native/assets-registry": "npm:0.81.0"
25907+
"@react-native/codegen": "npm:0.81.0"
25908+
"@react-native/community-cli-plugin": "npm:0.81.0"
25909+
"@react-native/gradle-plugin": "npm:0.81.0"
25910+
"@react-native/js-polyfills": "npm:0.81.0"
25911+
"@react-native/normalize-colors": "npm:0.81.0"
25912+
"@react-native/virtualized-lists": "npm:0.81.0"
25913+
abort-controller: "npm:^3.0.0"
25914+
anser: "npm:^1.4.9"
25915+
ansi-regex: "npm:^5.0.0"
25916+
babel-jest: "npm:^29.7.0"
25917+
babel-plugin-syntax-hermes-parser: "npm:0.29.1"
25918+
base64-js: "npm:^1.5.1"
25919+
commander: "npm:^12.0.0"
25920+
flow-enums-runtime: "npm:^0.0.6"
25921+
glob: "npm:^7.1.1"
25922+
invariant: "npm:^2.2.4"
25923+
jest-environment-node: "npm:^29.7.0"
25924+
memoize-one: "npm:^5.0.0"
25925+
metro-runtime: "npm:^0.83.1"
25926+
metro-source-map: "npm:^0.83.1"
25927+
nullthrows: "npm:^1.1.1"
25928+
pretty-format: "npm:^29.7.0"
25929+
promise: "npm:^8.3.0"
25930+
react-devtools-core: "npm:^6.1.5"
25931+
react-refresh: "npm:^0.14.0"
25932+
regenerator-runtime: "npm:^0.13.2"
25933+
scheduler: "npm:0.26.0"
25934+
semver: "npm:^7.1.3"
25935+
stacktrace-parser: "npm:^0.1.10"
25936+
whatwg-fetch: "npm:^3.0.0"
25937+
ws: "npm:^6.2.3"
25938+
yargs: "npm:^17.6.2"
25939+
peerDependencies:
25940+
"@types/react": ^19.1.0
25941+
react: ^19.1.0
25942+
peerDependenciesMeta:
25943+
"@types/react":
25944+
optional: true
25945+
bin:
25946+
react-native: cli.js
25947+
checksum: 10c0/73faa2dc9143abc91d23d926320b69cd0a3345396b65747b0d0d197ffab4034424940c0ec85512b6a7ffab52cf3bdefef7160fdebf16303863dddcf7ffe8a673
25948+
languageName: node
25949+
linkType: hard
25950+
2590125951
"react-refresh@npm:*":
2590225952
version: 0.17.0
2590325953
resolution: "react-refresh@npm:0.17.0"
@@ -27135,7 +27185,7 @@ __metadata:
2713527185
prettier: "npm:3.6.2"
2713627186
react: "npm:19.1.0"
2713727187
react-dom: "npm:19.1.0"
27138-
react-native: "npm:0.81.0"
27188+
react-native: "patch:react-native@npm%3A0.81.0#~/.yarn/patches/react-native-npm-0.81.0-612367b09d.patch"
2713927189
react-native-safe-area-context: "npm:^5.0.0"
2714027190
react-native-screens: "npm:^4.1.0"
2714127191
react-test-renderer: "npm:^19.0.0"

0 commit comments

Comments
 (0)