Skip to content

Commit

Permalink
test: mock react-native-webview (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
laggu authored Dec 1, 2024
1 parent be3acfc commit f51fe93
Show file tree
Hide file tree
Showing 6 changed files with 510 additions and 2 deletions.
7 changes: 7 additions & 0 deletions apps/app/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import { it } from '@jest/globals'
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer'

jest.mock('react-native-webview', () => {
const { View } = require('react-native')
return {
WebView: View,
}
})

it('renders correctly', () => {
renderer.create(<App />)
})
3 changes: 1 addition & 2 deletions apps/app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autoli
rootProject.name = 'fienmee-app'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
android.useAndroidX=true
android.enableJetifier=true

119 changes: 119 additions & 0 deletions apps/app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,72 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-safe-area-context (4.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- react-native-safe-area-context/common (= 4.14.0)
- react-native-safe-area-context/fabric (= 4.14.0)
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-safe-area-context/common (4.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-safe-area-context/fabric (4.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- react-native-safe-area-context/common
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-webview (13.12.4):
- DoubleConversion
- glog
Expand Down Expand Up @@ -1530,6 +1596,51 @@ PODS:
- React-logger (= 0.76.2)
- React-perflogger (= 0.76.2)
- React-utils (= 0.76.2)
- RNScreens (4.3.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-RCTImage
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNScreens/common (= 4.3.0)
- Yoga
- RNScreens/common (4.3.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-RCTImage
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- SocketRocket (0.7.1)
- Yoga (0.0.0)

Expand Down Expand Up @@ -1571,6 +1682,7 @@ DEPENDENCIES:
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-webview (from `../node_modules/react-native-webview`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
Expand Down Expand Up @@ -1599,6 +1711,7 @@ DEPENDENCIES:
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
- ReactCodegen (from `build/generated/ios`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNScreens (from `../node_modules/react-native-screens`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -1677,6 +1790,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
React-microtasksnativemodule:
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-webview:
:path: "../node_modules/react-native-webview"
React-nativeconfig:
Expand Down Expand Up @@ -1733,6 +1848,8 @@ EXTERNAL SOURCES:
:path: build/generated/ios
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNScreens:
:path: "../node_modules/react-native-screens"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand Down Expand Up @@ -1772,6 +1889,7 @@ SPEC CHECKSUMS:
React-logger: 81d58ca6f1d93fca9a770bda6cc1c4fbfcc99c9c
React-Mapbuffer: 726951e68f4bb1c2513d322f2548798b2a3d628d
React-microtasksnativemodule: 7a69a9b8fded72ea3cf81923ecf75cad5558ed26
react-native-safe-area-context: 2500e4fe998caad50ad3bc51ec23ef951308569e
react-native-webview: 0bd56be54d01756f20eb942dad37a2cd22a6def2
React-nativeconfig: 470fce6d871c02dc5eff250a362d56391b7f52d6
React-NativeModulesApple: 6297fc3136c1fd42884795c51d7207de6312b606
Expand Down Expand Up @@ -1800,6 +1918,7 @@ SPEC CHECKSUMS:
React-utils: ed6cb7ba089ac0856aa104df12691e99abbf14e1
ReactCodegen: 93b271af49774429f34d7fd561197020d86436e2
ReactCommon: 208cb02e3c0bb8a727b3e1a1782202bcfa5d9631
RNScreens: 44a3e358d5ccd7815c5ae9148988c562826992b2
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 96872ee462cfc43866ad013c8160d4ff6b85709b

Expand Down
5 changes: 5 additions & 0 deletions apps/app/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module.exports = {
preset: 'react-native',
testEnvironment: 'jsdom',
moduleFileExtensions: ['ts', 'tsx', 'js'],
transformIgnorePatterns: [
'<rootDir>/node_modules/(react-clone-referenced-element|@react-native-community|react-navigation|@react-navigation/.*|@unimodules/.*|native-base|react-native-code-push)',
],
}
2 changes: 2 additions & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@jest/globals": "^29.7.0",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
Expand All @@ -35,6 +36,7 @@
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"jest-environment-jsdom": "^29.7.0",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
},
Expand Down
Loading

0 comments on commit f51fe93

Please sign in to comment.