gpt4 book ai didi

javascript - 指定的插件 0,提供了 "default"的无效属性(Jest React Native)

转载 作者:行者123 更新时间:2023-11-30 14:17:17 24 4
gpt4 key购买 nike

嘿,我只是想运行一个简单的测试,在运行使用 jest 的“ yarn 测试”后,我一直遇到这个错误。

Plugin 0 specified in "/Users/Documents/Dev/appname/node_modules/babel-preset-react-native/index.js" provided an invalid property of "default" (While processing preset: "/Users/Documents/Dev/appname/node_modules/babel-preset-react-native/index.js")

at Plugin.init (node_modules/babel-core/lib/transformation/plugin.js:131:13)
at Function.normalisePlugin (node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
at Array.map (<anonymous>)
at OptionManager.resolvePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)

这是我的 package.json,我缺少什么,我确定它是配置问题而不是测试问题。

{
"name": "appname",
"version": "0.0.1",
"private": true,
"rnpm": {
"assets": [
"resources/fonts"
]
},
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"lodash": "^4.17.10",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-autocomplete-input": "^3.5.0",
"react-native-code-push": "^5.4.2",
"react-native-elements": "^1.0.0-beta2",
"react-native-form-validator": "^0.2.0",
"react-native-image-pan-zoom": "^2.1.9",
"react-native-image-zoom-viewer": "^2.2.18",
"react-native-material-dropdown": "^0.11.1",
"react-native-remote-svg": "^1.3.0",
"react-native-vector-icons": "^5.0.0",
"react-native-version-number": "^0.3.5",
"react-navigation": "^2.11.2"
},
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "^5",
"jest": "23.5.0",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}

最佳答案

不知道你是否已经解决了这个问题,但我遇到了同样的问题,我能够使用 RN 0.56 使事情再次正常工作。我改变了这个:

"babel-preset-react-native": "^5",

"babel-preset-react-native": "4.0.0",

这里是关于这个问题的完整讨论:https://github.com/storybooks/storybook/issues/3897

如果以上破坏了你的 react-native 环境,另一种解决方案是安装 babel-bridge:

npm install babel-core@7.0.0-bridge.0 --save-dev

关于javascript - 指定的插件 0,提供了 "default"的无效属性(Jest React Native),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53378066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com