gpt4 book ai didi

android - Jest testing::测试失败并且错误路由到\react-native-vector-icons

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:07:37 25 4
gpt4 key购买 nike

您好,我一直在尝试运行“npm test”,遇到了一些与 native-base 类似的问题,但通过在 transformIgnorePatterns 键中放置“native-base-shoutem-theme|||tcomb-form-native”解决了我的 Package.json 文件。

但还没有找到如下所示的 react-native-vector-icons 的解决方案

    myapp@0.0.1 test D:\ReactWorkSpace\myapp
jest
PASS tests\index.ios.js
FAIL tests\index.android.js
● Test suite failed to run
D:\ReactWorkSpace\myapp\node_modules\native-base\node_modules\react-native-vector-icons\Ionicons.js:6
import createIconSet from './lib/create-icon-set';
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object.<anonymous> (node_modules/native-base/dist/src/basic/IconNB.js:5:15)
at Object.<anonymous> (node_modules/native-base/dist/src/index.js:16:13)
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.189s, estimated 8s
Ran all test suites.
npm ERR! Test failed. See above for more details

我的 package.json 文件是

{
"name": "myapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"js-base64": "^2.1.9",
"moment": "^2.18.1",
"native-base": "^2.2.1",
"react": "16.0.0-alpha.12",
"react-native": "0.46.0",
"react-native-animatable": "^1.2.2",
"react-native-button": "^2.0.0",
"react-native-drawer": "^2.3.0",
"react-native-linear-gradient": "^2.2.0",
"react-native-material-design": "^0.3.7",
"react-native-material-kit": "^0.4.1",
"react-native-material-ui": "^1.12.0",
"react-native-vector-icons": "^4.2.0",
"react-navigation": "^1.0.0-beta.11",
"react-toolbox": "^2.0.0-beta.12",
"render-if": "^0.1.1"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.1.0",
"jest": "^20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!react-native|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
]
}
}

最佳答案

将此添加到您的 package.json。它解决了你的问题:)

"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"/node_modules/(?!native-base)/"
],

...
}

关于android - Jest testing::测试失败并且错误路由到\react-native-vector-icons,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45981590/

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