react-native - Jest 在 react-native-modalize 上失败了?
问题描述
我的笑话脚本在 react-native-modalize 上失败了。为什么 jest 在这一点上失败了
错误
● Test suite failed to run
TypeError: Cannot read property 'minor' of undefined
at Object.<anonymous> (node_modules/react-native-modalize/lib/utils/devices.js:20:76)
at Object.<anonymous> (node_modules/react-native-modalize/lib/utils/use-dimensions.js:25:19)
我的 package.json 在下面,
包装.json
{
"name": "vendor",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "npx react-native run-android",
"ios": "react-native run-ios"
},
"dependencies": {
"@jest/globals": "^27.0.6",
"@react-native-async-storage/async-storage": "^1.15.6",
"react-native-modal": "^12.1.0",
"react-native-modalize": "^2.0.8",
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/runtime": "^7.15.3",
"@codler/react-native-keyboard-aware-scroll-view": "1.0.1",
"@react-native-community/eslint-config": "^3.0.0",
"@testing-library/jest-native": "^4.0.2",
"@testing-library/react-native": "^7.2.0",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.6",
"detox": "^17.14.9",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"jest": "^26.6.3",
"jest-circus": "^26.6.0",
"jsdom": "17.0.0",
"jsdom-global": "3.0.2",
"metro-react-native-babel-preset": "^0.66.2",
"prettier": "^2.3.2",
"react-native-rename": "^2.9.0",
"react-test-renderer": "17.0.2"
},
"jest": {
"coverageReporters": [
"text"
],
"reporters": [
"default",
"jest-junit"
],
"preset": "react-native",
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
],
"transformIgnorePatterns": [
"/node_modules/(?!react-native)/.+"
],
"setupFiles": [
"./node_modules/react-native-gesture-handler/jestSetup.js"
]
},
"jest-junit": {
"output": "output/coverage/junit/junit.xml",
"usePathForSuiteName": "true"
}
}
我在升级之前升级了 react-native 版本,它工作正常。
为什么会失败?我应该降级任何软件包还是我错过了什么?
解决方案
它已在此合并中修复。所以,继续更新你的版本react-native-modalize
正如您可能已经看到的,node_modules/react-native-modalize/lib/utils/devices.js
它与 reactNativeVersion 有关。
推荐阅读
- angular - primeng 表中自定义过滤布尔值的问题
- javascript - AWS DynamoDB 解析返回的数据
- html - EJS JSON解析
- c# - CS7069 C# 对“组件”类型的引用声称它是在“系统”中定义的,但找不到
- mysql - 从 Azure Mysql 导出数据的最有效方法是什么?
- neo4j - NEO4J:获取特定演员没有表演的电影
- java - 为什么即使使用 hasNextInt() 方法我也会收到 inputMismatchException?
- angular - 循环依赖角6
- bash - 带有异步文件的 Bash 连接器
- c# - 为什么我的带有计时器的 C# Winforms 程序在一天后就卡住了?