簡體   English   中英

指定了插件0,提供了“ default”的無效屬性(Jest React Native)

[英]Plugin 0 specified, provided an invalid property of “default” (Jest React Native)

嘿,我只是想運行一個簡單的測試,而在運行使用jest的“ yarn test”后,我一直遇到此錯誤。

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 env,則另一個解決方案是安裝babel-bridge:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM